java json 省市級聯實例代碼
// 獲取國家省市區(qū)信息
$(document).ready(function(){
//從程序獲取json格式的數據
var info = $request.getAttribute("manualOrderAreaInfo");
var provinceInfo = $("#provinceId");
var cityId = $("#cityId");
//清空信息
provinceInfo.empty();
//循環(huán)獲取信息
$.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

