JS实现全国三级联动

//引用js文件area.js

<script src="/javascripts/area.js" type="text/javascript"></script>

  <li><label>全国 省 市 县 三级级联:</label> <i>*</i> <select id="s_province" name="s_province" class="area" ></select>&nbsp;&nbsp;
    <select id="s_city" name="s_city" class="area" ></select>&nbsp;&nbsp;
    <select id="s_county" name="s_county" class="area" ></select>
    <script class="resources library" src="js/area.js"
    type="text/javascript"></script> <script type="text/javascript">_init_area();</script>
  </li>

 

  /*
    * 全国三级城市联动 js版 //编辑
  */
      function updates(province,city,county){//方法
        $("#s_province option").each(function(){
      if($(this).val()==province){
        $(this).attr('selected',true)
        change(1);
      }
    });
        $("#s_city option").each(function(){
      if($(this).val()==city){
        $(this).attr('selected',true)
      change(2);
      }
    });
        $("#s_county option").each(function(){
      if($(this).val()==county){
        $(this).attr('selected',true)
      }
    });
  }

  var arr_area = address.split("-");

  updates(arr_area[0] ,arr_area[1],arr_area[2]) //修改获取省市县

转载于:https://www.cnblogs.com/nonoleng/p/3816590.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值