在php中填充子表单

时间:2015-09-20 23:23:13

标签: php html mysql subform

我正在尝试将子表单插入到我的一个表单中。在我的表单中有一个表和两个按钮,一个链接到添加按钮,另一个链接到编辑按钮。目标是能够单击其中一个按钮并弹出一个新窗口以添加或编辑子窗体中的数据。主窗体是父记录,弹出窗口是子记录。

这是顶部的PHP代码:

if (isset($_POST['save'])){
    if($_POST['deletePackage'] == "yes"){
        Transaction::delete('transaction', "transactionId={$_POST['transactionId']}");
        $session->message('Transaction Deleted!');
        redirectTo('abs_mainMenu.php');
    } elseif($_POST['save'] == "yes") {
        unset($_POST['deletePackage']);
        unset($_POST['save']);
       //Transaction::update('transaction', array_filter($_POST), "transactionId={$_POST['transactionId']}");
       //redirectTo('abs_createNormalCase.php');
    }
} else {
    $transaction = new Transaction();
    $transaction->insert('transaction', array('status' => 'PD'));
    $transactionId = $database->insertId();
}

这是包含子表单的部分:

<td width="47%" valign="top">
    <table border="0" cellpadding="0" cellspacing="2" width="100%">
        <tr>
            <td colspan="4" class="content-label-sub">Offender Aliases and Maiden Names</td>
        </tr>
        <tr>
            <td class="small-black-font">
                <span style="position:relative;left:0">Last</span>
                <span style="position:relative;left:20%">First</span>
                <span style="position:relative;left:40%">Middle</span>
                <span style="position:relative;left:75%">Suffix</span>
            </td>
        </tr>
        <tr>
            <td rowspan="3" valign=="top">
                <select name="aliaseSelect" size="4" onclick="clickOfficeList()" style="width:100%; height: 100px;" class="select-text">
<?php
$aliases = Aliases::findByTransId(3375139);
foreach($aliases as $aliase){
?>
                    <option value="<?= $aliase->id ?>"> <?= $aliasesLastName.", ".$aliasesFirstName." ".$aliasesMiddleName." ".$aliaseSuffix ?></option>
<?php }?>
                </select>
            </td>
        </tr>
    </table>
    <input type="button" value="Add" onclick="addAliase(<?= $transactionId ?>)"><input type="button" value="Edit" onclick="editAliase(<?= $transactionId ?>)">
</td>

添加弹出窗口如下:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript">
            /*<![CDATA[*/
            document.cookie = "IV_JCT=%2Fjabs; path=/";
            /*]]>*/
        </script>
        <title>Joint Automated Booking System - Limited Official Use</title>
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="Expires" content="-1">
        <link href="../css/content.css" rel="stylesheet" type="text/css">
        <link href="../css/common.css" rel="stylesheet" type="text/css">
    </head>
    <body class="table-color2-narrow" leftmargin="4" topmargin="0" rightmargin="4" bottommargin="0" marginwidth="1" marginheight="1">
        <table border="0" cellpadding="0" cellspacing="2" width="50%">
            <tr>
                <td colspan="4" class="content-label-sub">Offender Name</td>
            </tr>
            <tr>
                <td width="15%" align="left" nowrap class="small-black-font">Last *</td>
                <td width="85%" nowrap class="small-black-font"><input type="text" name="offenderLastName" maxlength="50" size="25" value="" class="small-black-font" autofocus required></td>
            </tr>
            <tr>
                <td width="15%" align="left" nowrap class="small-black-font">First *</td>
                <td width="85%" nowrap class="small-black-font"><input type="text" name="offenderFirstName" maxlength="50" size="20" value="" class="small-black-font" required></td>
            </tr>
            <tr>
                <td width="15%" align="left" nowrap class="small-black-font">Middle</td>
                <td width="85%" nowrap class="small-black-font"><input type="text" name="offenderMiddleName" maxlength="50" size="20" value="" class="small-black-font"></td>
            </tr>
                <td align="left" class="small-black-font">Suffix</td>
                <td nowrap class="small-black-font">
                    <select name="offenderNameSuffix" id="offenderNameSuffix">
                        <option value=""></option>
                        <option value="I">I</option>
                        <option value="II">II</option>
                        <option value="III">III</option>
                        <option value="JR">JR</option>
                        <option value="MD">MD</option>
                        <option value="PHD">PHD</option>
                        <option value="SR">SR</option>
                    </select>
                </td>
        </table>
    </body>
</html>

我无法弄清楚如何用信息填充原始页面上的表格。

0 个答案:

没有答案