我的网页包含子信息,例如family type
,name
,gender
,date of birth
,country 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
<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
<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>
但是如果我有一个以上的孩子,我怎样才能在同一个页面中添加新字段以允许我输入我的第二或第三个孩子信息?
答案 0 :(得分:0)
您可以使用JavaScript通过提供标题为“添加更多”的按钮或链接来动态添加更多文本字段,并且当单击此链接时,新字段将添加到子字段下方的表单中,此代码中包含问题可以提供帮助:Add more text fields dynamically in new line (html)