我有一个包含两个字段的SQL表:ModuleTitle和ModuleCode,例如
ModuleCode | ModuleTitle
COC001 |机器人
COB290 |团队项目
COC003 |电子商务规划与营销
在我的网站上,我有两个下拉菜单:module_title和module_code:
<?php
//build search string and call results
$strSQL="SELECT * FROM modules ORDER BY ModuleTitle ASC";
$result = mysql_query($strSQL) or die($strSQL."<br/><br/>".mysql_error());
if(mysql_num_rows($result)!=0){//if there are any results
echo '<select name="module_title"><option></option>';
while($row=mysql_fetch_array($result)){
//loop through the array of results until are no more
//output an option for each
echo "<option value=".$row['ModuleTitle'].">".$row['ModuleTitle']."</option>";
<select name="module_code" size="1">
<option value=" " selected="selected"></option>
</select>
}
echo '</select>';//close select
}
?>
<select name="module_code" size="1">
<option value=" " selected="selected"></option>
</select>
当用户选择module_title中的选项时,我希望module_code的内容实时填充匹配字段 Module_Code 。如何实现这一目标?