0

我有一个包含子信息的页面family type,例如,,,,,,。namegenderdate of birthcountry of birth

代码

    <td colspan="2" class="title_all_u">Family Member 2 (Child)</td>
            </tr>
            <tr>
              <td width="50%" class="pk">Family Type</td>
              <td width="50%" class="pk_2"><input name="family_child_type" type="text" class="textfield_word" id="family_child_type" value="<?php echo $family_child_type ?>" /></td>
            </tr>
            <tr>
              <td class="pk">Name</td>
              <td width="50%" class="pk_2"><input name="family_child_name" type="text" class="textfield_word" id="family_child_name" value="<?php echo $family_child_name ?>" /></td>
            </tr>
            <tr>
              <td class="pk">Gender Key</td>
              <td class="pk_2">
              <input type="radio" name="family_child_gender" id="family_child_gender" value="Male" <?php if ($family_child_gender=="Male"){ ?> checked <?php } ?>/>
               Male   &nbsp;  
               <input type="radio" name="family_child_gender" id="family_child_gender" value="Female" <?php if ($family_child_gender=="Female"){ ?> checked <?php } ?> />
              Female
                </td>
            </tr>
            <tr>
              <td class="pk">Date of Birth</td>
              <td class="pk_2"><input name="family_child_date_birth" type="text" class="tcal" id="family_child_date_birth" value="<?php echo date_create($family_child_date_birth)->format('d-m-Y');?>" readonly="readonly"/></td>
            </tr>
            <tr>
              <td class="pk">Country of Birth</td>
              <td class="pk_2">
              <?php
                $query = "SELECT country_type FROM country";
                $result = mysql_query ($query); ?>
                <select name="family_child_country" >
                <?php while($row = mysql_fetch_array($result)){ ?>
                <option value="<?php echo $row['country_type']?>"  <?php if ( $family_child_country ==  $row['country_type']){ ?> selected <?php } ?>>
                <?php echo $row['country_type']?></option>
                <?php }?>
                </select>
                </td>
            </tr>
            <tr>
              <td class="pk">Nationality</td>
              <td class="pk_2">
                <?php
                $query = "SELECT nationality_type FROM nationality";
                $result = mysql_query ($query); ?>
                <select name="family_child_nationality" >
                <?php while($row = mysql_fetch_array($result)){ ?>
                <option value="<?php echo $row['nationality_type']?>"  <?php if ( $family_child_nationality ==  $row['nationality_type']){ ?> selected <?php } ?>>
                <?php echo $row['nationality_type']?></option>
                <?php }?>
                </select>
                </td>
            </tr>
            <tr>
              <td class="pk">IC Number</td>
              <td width="50%" class="pk_2"><input name="family_child_ic_num" type="text" class="textfield_word" id="family_child_ic_num" value="<?php echo $family_child_ic_num ?>" /></td>
            </tr>
            <tr>
              <td class="pk">Passport No.</td>
              <td width="50%" class="pk_2"><input name="family_child_pass_num" type="text" class="textfield_word" id="family_child_pass_num" value="<?php echo $family_child_pass_num ?>" /></td>
            </tr>
            <tr>
              <td class="pk">Education/Training</td>
              <td width="50%" class="pk_2"><input name="family_child_education" type="text" class="textfield_word" id="family_child_education" value="<?php echo $family_child_education ?>" /></td>
            </tr>
            <tr>
              <td class="pk">Handicapped</td>
              <td width="50%" class="pk_2"><input name="family_child_handicaped" type="text" class="textfield_word" id="family_child_handicaped" value="<?php echo $family_child_handicaped ?>" /></td>
            </tr>
            <tr>
              <td class="pk">Child Custody</td>
              <td width="50%" class="pk_2"><input name="family_child_custody" type="text" class="textfield_word" id="family_child_custody" value="<?php echo $family_child_custody ?>" /></td>
            </tr>
            <tr>
              <td class="pk">Married</td>
               <td class="pk_2">
               <input type="radio" name="family_child_married_status" id="family_child_married_status" value="Yes" <?php if ($family_child_married_status=="Yes"){ ?> checked <?php } ?>/>
               Yes   &nbsp;  
               <input type="radio" name="family_child_married_status" id="family_child_married_status" value="No" <?php if ($family_child_married_status=="No"){ ?> checked <?php } ?> />
              No  </td>
            </tr>
            <tr>
              <td class="pk">Employed</td>
              <td width="50%" class="pk_2"><input name="family_child_employed" type="text" class="textfield_word" id="family_child_employed" value="<?php echo $family_child_employed ?>" />
<input type="button"  size="3" cols="30" value="Add Child" onClick="addNew()">
</td>
            </tr>
            <tr>

但是如果我有超过 1 个孩子,我如何在同一页面中添加新字段以允许我输入我的第二个或第三个孩子信息?

4

1 回答 1

0

您可以使用 JavaScript 通过提供标题为“添加更多”的按钮或链接来动态添加更多文本字段,当单击此链接时,会在子字段下方的表单中添加一个新字段,此问题中的代码可以提供帮助:在新行(html)中动态添加更多文本字段

于 2013-10-02T06:10:38.920 回答