如何在编辑时间内从选定的国家/地区获取状态?
这是针对国家/地区:
<div class="col-md-6">
<select class="select2 form-control custom-select " style="width: 100%; height:36px;" name="country" onChange="getState(this.value);" id="country">
<option>Select Country</option>
<?php foreach($countries as $coun) {
foreach($ed as $edit) /*edit mode*/
{
if($edit->country_id==$coun->id)
{
?>
<option value="<?php echo $coun->id; ?>" selected="selected"> <?php echo $coun->name; ?> </option>
<?php
}}
?>
<option value="<?php echo $coun->id; ?>"> <?php echo $coun->name; ?> </option>
<?php
} ?>
</select>
</div>
这是针对状态:
<div class="col-md-6">
<select class="select2 form-control custom-select" style="width: 100%; height:36px;" name="state" id="state-list" onChange="getCity(this.value);">
<option>Select State</option>
</select>
</div>
function getState(val) {
$.ajax({
type: "POST",
url: "getState.php",
data:'country_id='+val,
success: function(data){
$("#state-list").html(data);
//getCity();
}
});
}
答案 0 :(得分:0)
尝试以下代码:
function getState(val) {
$.ajax({
type: "POST",
url: "getState.php",
data:{country_id:val},
success: function(data){
$("#state-list").html(data);
//getCity();
}
});
}