我想获取用户从城市列表中选择的城市的商店地址。我使用 ajax 来显示城市。
$('.cn').change(function(){
$('.st1 option').remove();
$('.st1').append("<option value=''><Select city></option>");
var curr=$(this).val();
$.get('includes/pages/getcity.php',{cnid:curr},function(resp){
var obj = jQuery.parseJSON(resp);
$.each(obj, function() {
$data="<option value='"+this.id +"'>"+ this.city +"</option>";
$('.st1').append($data);
});
});
});
State <select name="state_id" class="select cn state_textbox" >
<option>---Select State--</option>
<?php
$query="select * from state";
$result=mysql_query($query);
while($row=mysql_fetch_assoc($result)){
if($row['state_id']==0){
echo "<option value='".$row['id']."'>".$row['state']."</option>";
}
}
?>
</select> <br><br><br>
City<select class="st1 state_textbox" name="st1" style="margin-left:35px" >
<option selected="selected">-- Select your city --</option>
</select>