zoukankan      html  css  js  c++  java
  • java json 省市级联

     1 //     获取国家省市区信息
     2 $(document).ready(function(){
     3 
     4 //从程序获取json格式的数据
     5 var info = $request.getAttribute("manualOrderAreaInfo");
     6 
     7 
     8 var provinceInfo = $("#provinceId");
     9 var cityId = $("#cityId");
    10 
    11 //清空信息
    12 provinceInfo.empty();
    13 
    14 //循环获取信息
    15 $.each(info.area, function(idx,item){
    16 if(idx == 0){
    17 return true;
    18 }
    19 //alert("name:"+idx+",areaId:"+item.areaId+",areaName:"+item.areaName+",areaParentId:"+item.parentId);
    20 
    21 //这里父类ID为1是城市信息
    22 if(item.parentId == 1){
    23 $("<option value="+item.areaId+">"+item.areaName+"</option>").appendTo(provinceInfo);
    24 }
    25 });
    26 //获取对应的城市信息
    27 $("#provinceId").change(function(){
    28 var tempInfo = $("#provinceId").val();
    29 cityId.empty();
    30 $.each(info.area, function(indexInfo,item){
    31 if(indexInfo == 0){
    32 return true;
    33 }
    34 if(item.parentId == tempInfo){
    35 $("<option value="+item.areaId+">"+item.areaName+"</option>").appendTo(cityId);
    36 }
    37 });
    38 });
    39 });
    <tr>
                        <th style="120px;">收货人省份</th>
    <!--                    <td style="270px;"><input type="text" value="$!{manualEntryOrder.goodReceiverProvince}" name="manualEntryOrder.goodReceiverProvince" style="150px;"  maxlength="255"/></td>-->
                            <td style=" 270px;">
                                <select id="provinceId" name="staffProvince" style=" 154px;">
                                </select>
                                
                            </td>
                        <th style="140px;">收货人城市</th>
                        <td style="270px;">
    <!--                        <input type="text" value="$!{manualEntryOrder.goodReceiverCity}" name="manualEntryOrder.goodReceiverCity" style="150px;"  maxlength="255"/>-->
                                <select id="cityId" name="staffProvince" style=" 154px;">
                                    <option value="--">---请选择城市信息---</option>
                                </select>
                        </td>
                    </tr>
  • 相关阅读:
    运行JBoss 5.1.0 GA时出现Error installing to Instantiated:name=AttachmentStore state=Described错误的解决办法
    java中log4j的使用体验
    C#:DataTable映射成Model
    使用MyBatis搭建一个访问mysql数据库的简单示例
    netty的拆包和粘包
    netty的HelloWorld演示
    ByteBuffer详解
    汉字拼音缩写输出工具类
    mysql错误汇集
    mysql的定时任务
  • 原文地址:https://www.cnblogs.com/jayGold/p/3314553.html
Copyright © 2011-2022 走看看