所以我试图让一组文本框显示当前选择框的信息,该选择框是从 PHP MySQL 请求动态创建的。选择生成正常,但仅填充表格的最后一行。我想让它在您更改选择框时更新文本框以反映新信息。
从 MySQL 获取信息的当前代码:
<div id="edithidden" style="display:none;">
<div id="prompt"><strong>Section to Edit:</strong></div>
<div id="answer">
<form id="editorginfo" action="" method="post">
<select id="edit">
<option>Section to Edit</option>
<?php
$query = $db->query("SELECT ID, OrgName, Phone, Location FROM emergencyorg");
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$pid=$row['ID'];
$name=$row['OrgName'];
$phone=$row['Phone'];
$loc=$row['Location'];
echo "<option value='" . $pid . "' ";
if($row['OrgName']==$pid){
echo ' selected';
}
echo">" . $name . "</option>";
}
?>
</select>
</div>
<div id="prompt">Organization Name:</div>
<div id="answer">
<input type="text" name="editorgname" id="editorgname" value="<?=$name?>"/>
</div>
<div id="prompt">Organization Phone Number:</div>
<div id="answer">
<input type="text" name="editorgphone" id="editorgphone" value="<?=$phone?>"/>
</div>
<div id="prompt">Orginization Location:</div>
<div id="answer">
<input type="text" name="editorglocation" id="editorglocation" value="<?=$loc?>"/>
</div>
<div id="prompt">
<input type="submit" id="editorg" name="editorg" value="Update Information" />
</div>
</form>
</div>
这是否必须使用 AJAX 来完成?
再次提前感谢!