我想customer_address
,customer_city
,customer_state
和customer_zip
自動填充onChange
的customer_name
下拉列表。我環顧四周,但我很難過。如何從mysql查詢結果onChange下拉菜單自動填充文本框的值?
請幫忙。
<form action="" method="post" name="booking_form" class="booking" style="width: auto">
<select name="customer_name" onChange="???????">
<option value="index.php">Click to select your school </option>
<?php
// Make a MySQL Connection
$username="";
$password="";
$database="";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query = "SELECT * FROM table";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$school = $row['customer_name'];
$phone = $row['customer_phone'];
$address = $row['customer_address'];
$city = $row['customer_city'];
$state = $row['customer_state'];
$zip = $row['customer_zip'];
$notes = $row['customer_notes'];
?>
<option value="<?php echo $school; ?>"><?php echo "$school".", "."$city"; ?></option>
<?php }
?></select>
<input type="text" name="customer_address">
<input type="text" name="customer_city">
<input type="text" name="customer_state">
<input type="text" name="customer_zip">
</form>
那麼你嘗試過這麼遠嗎? –
http://stackoverflow.com/questions/4344747/jquery-load-form-elements-through-ajax-from-onchange-event-of-drop-down-box?rq=1 – Nathan
編輯你的問題,並在那裏添加代碼在您的評論 – Yaroslav