我正在尝试制作级联下拉列表,我希望当用户选择区域然后相应地填充城市下拉列表..
JS:
$(document).ready(function() {
$('#region').change(function() {
var region = $(this).val();
$.post('get_region.php', {
region: region
}, function(data) {
$('#district_div').html(data);
});
});
PHP:
<?php
require_once('../db/connect.php');
$region=$_POST['region'];
$q=mysql_query("select name from city where region='$region'");
$row=mysql_fetch_array($q);
echo $row['name'];
?>
HTML*强文本*
<div class="controls">
<select class="bootstrap-select" name="region" id="region">
<option value="">Choose</option>
//from database
<?php echo $region_result; ?>
</select>
</div>
<select class="bootstrap-select" name="district" id="district" >
<div id='district_div'></div>
</select>