java json 省市级联实例代码
// 获取国家省市区信息
$(document).ready(function(){
//从程序获取json格式的数据
var info = $request.getAttribute("manualOrderAreaInfo");
var provinceInfo = $("#provinceId");
var cityId = $("#cityId");
//清空信息
provinceInfo.empty();
//循环获取信息
$.each(info.area, function(idx,item){
if(idx == 0){
return true;
}
//alert("name:"+idx+",areaId:"+item.areaId+",areaName:"+item.areaName+",areaParentId:"+item.parentId);
//这里父类ID为1是城市信息
if(item.parentId == 1){
$("<option value="+item.areaId+">"+item.areaName+"</option>").appendTo(provinceInfo);
}
});
//获取对应的城市信息
$("#provinceId").change(function(){
var tempInfo = $("#provinceId").val();
cityId.empty();
$.each(info.area, function(indexInfo,item){
if(indexInfo == 0){
return true;
}
if(item.parentId == tempInfo){
$("<option value="+item.areaId+">"+item.areaName+"</option>").appendTo(cityId);
}
});
});
});
<tr>
<th style="width:120px;">收货人省份</th>
<!-- <td style="width:270px;"><input type="text" value="$!{manualEntryOrder.goodReceiverProvince}" name="manualEntryOrder.goodReceiverProvince" style="width:150px;" maxlength="255"/></td>-->
<td style="width: 270px;">
<select id="provinceId" name="staffProvince" style="width: 154px;">
</select>
</td>
<th style="width:140px;">收货人城市</th>
<td style="width:270px;">
<!-- <input type="text" value="$!{manualEntryOrder.goodReceiverCity}" name="manualEntryOrder.goodReceiverCity" style="width:150px;" maxlength="255"/>-->
<select id="cityId" name="staffProvince" style="width: 154px;">
<option value="--">---请选择城市信息---</option>
</select>
</td>
</tr>
相关文章
IDEA下lombok安装及找不到get,set的问题的解决方法
这篇文章主要介绍了IDEA下lombok安装及找不到get,set的问题的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-04-04
Elasticsearch查询及聚合类DSL语句宝典示例详解
这篇文章主要为大家介绍了Elasticsearch查询及聚合类DSL语句宝典示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-01-01


最新评论