function test(province_name,city_name,county_name){
$.ajax({
url: 'user.php?act=add_consignee',
type: 'POST',
dataType: 'json',
data:{province_name:province_name,city_name:city_name,county_name:county_name},
success: function(result){
console.log(result);
var province_id=result.province_id;
var county_id=result.county_id;
var city_id=result.city_id;
$("#selProvinces option:selected").val(result.province_id);//省
$("#selCities option:selected").val(result.city_id);//市
$("#selDistricts option:selected").val(result.county_id);//县区
$("#selProvinces option:selected").html(province_name);
$("#selCities option:selected").html(city_name);
$("#selDistricts option:selected").html(county_name);
}
});
}
<dl>
<dd class="diqu">
<select class="selector" name="province" id="selProvinces" onchange="region.changed(this, 2, 'selCities')">
<option value="0">请选择省</option>
{foreach from=$province_list item=province}
<option value="{$province.region_id}" {if $consignee.province eq $province.region_id or $province_on eq $province.region_id}selected{/if}>{$province.region_name}</option>
{/foreach}
</select>
<div id="updateTip3" class="operate_tips" style="display:none;">
<span class="operate_content">请选择省</span>
<span class="down_row"></span>
</div>
<select name="city" id="selCities" onchange="region.changed(this, 3, 'selDistricts')">
<option value="0">请选择市</option>
{foreach from=$city_list item=city}
<option value="{$city.region_id}" {if $consignee.city eq $city.region_id or $city_on eq $city.region_id}selected{/if}>{$city.region_name}</option>
{/foreach}
</select>
<div id="updateTip4" class="operate_tips" style="display:none;">
<span class="operate_content">请选择市</span>
<span class="down_row"></span>
</div>
<select name="district" id="selDistricts">
<option value="0">请选择区/县</option>
{foreach from=$district_list item=district}
<option value="{$district.region_id}" {if $consignee.district eq $district.region_id or $district_on eq $district.region_id}selected{/if}>{$district.region_name}</option>
{/foreach}
</select>
<div id="updateTip5" class="operate_tips" style="display:none;">
<span class="operate_content">请选择区/县</span>
<span class="down_row"></span>
</div>
网友评论