Home >php教程 >php手册 >城市四级联动菜单 省市区街道

城市四级联动菜单 省市区街道

WBOY
WBOYOriginal
2016-06-07 11:35:211751browse

desc
Javascript ;(function( $ , win , doc , undefined ){<br>         var indexs = 0;<br>          var obj = $('#getAddress select');<br>         var base_op = "<option>--请选择--";<br>          obj.change(function(){<br>             var this_val = $(this).val();<br>             var this_index = $(this).index() + 1;<br> <br>             $(this).parent('div').find('select').each(function(i){<br>                 if(i > (this_index-1)){<br>                     $(this).val(base_op);<br>                 }<br>             });<br> <br>             getAddress(this_val,this_index);<br>         });<br> <br>         //获取地址<br>         function getAddress(level,ix){<br>             $.get("__URL__/getAddress",{le : level},function(res){<br>                 var selNode = base_op;<br>                 for(var i=0;i                      selNode += '</option> <option>' + res[i].name + '</option>';<br>                 }<br> <br>                 obj.eq(ix).html(selNode);<br>             },"json");<br>         }<br> <br>         getAddress(0,indexs);<br> <br>      })(jQuery,window,document);//如果你的项目此处还有其他的js代码需要使用j/w/d对象PHPpublic function getAddress(){<br>     $level = I("get.le");<br>     $result = M("wd_addr")->where("pid =" . $level)->select();//这里我的项目是用的文件缓存,具体看你。这里仅仅演示<br>     $this->ajaxReturn($result,'JSON');<br> }HTML<div> <br>     <select><br>         <option>--请选择--</option> <br>     </select><br>     <select><br>         <option>--请选择--</option> <br>     </select><br>     <select><br>         <option>--请选择--</option> <br>     </select><br>     <select><br>         <option>--请选择--</option> <br>     </select><br> </div>

附件 wd.rar ( 338.02 KB 下载:84 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn