2
我需要根據先前選擇的下拉菜單填充另一個下拉菜單。請幫助。我的代碼如下。現在,我如何將先前選定的值傳遞給下一個下拉式的where子句?從基於先前選擇的數據庫查詢中選擇下拉菜單(PHP/HTML)
<td align="right">Country</td>
<td>
<select type="text" name="Country">
<option selected value="">Country Code</option>
<?php $result=mysql_query("SELECT CountryName FROM tbl_country");
while($row_result=mysql_fetch_row($result))
{ echo "<option value=\"$row_result[0]\">$row_result[1]</option>";}
?>
</select>*
</td>
<td align="right">Area</td>
<td>
<select type="text" name="Area">
<option selected value="">Area</option>
<?php $result=mysql_query("select Area from tbl_area where CountryName='???'");
while($row_result=mysql_fetch_row($result))
{ echo "<option value=\"$row_result[0]\">$row_result[0]</option>";}
?>
</select>*
</td>
如何將選定的國家名稱設置爲第二個查詢where子句? 在此先感謝。
您需要向由第一個選擇框的OnChange事件觸發的服務器發送AJAX請求。一旦用戶在第一個選擇框中選擇了一個值,OnChange事件觸發,您捕獲該值,使用AJAX請求將其發送到服務器,然後用結果填充第二個選擇框。 – 2013-02-20 15:13:57
你能給我舉個例子嗎? – riad 2013-02-20 15:16:21