2015最新省市地区数据级联效果
来源:互联网 发布:猫叔100的淘宝 编辑:程序博客网 时间:2024/06/04 17:42
下载地址:https://github.com/vsiryxm/city
代码如下:
<!DOCTYPE html><head><meta charset="utf-8" /><meta author="simon(QQ42564096)" /><title>2015最新省市地区数据级联效果</title><script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script><script type="text/javascript" src="./js/city.js"></script></head><body><select name="province" id="province"><option value="">=请选择=</option></select><select name="city" id="city"> <option value="">=请选择=</option></select><select name="area" id="area"> <option value="">=请选择=</option></select><script type="text/javascript"> $(document).ready(function(){ var init_prov = '320000'; //江苏省 var init_city = '320500'; //苏州市 var init_area = '320508'; //姑苏区 var first_option = "<option value=''>=请选择=</option>"; get_province(); if(init_city != '' && init_city !=undefined) get_city(init_prov); if(init_area != '' && init_area !=undefined) get_area(init_city); $("select[name='province']").change(function(){ $("select[name='city']").html(first_option); $("select[name='area']").html(first_option); init_prov = '', init_city='', init_area=''; get_city($(this).val()); }); $("select[name='city']").change(function(){ get_area($(this).val()); }); //获取省份 function get_province(){ $("select[name='province']").html(); var province = first_option; $(_city_list).each(function(index){ if(0 == _city_list[index].parent_id){ province = province + "<option value='" + _city_list[index].area_id + "'>"+ _city_list[index].area_name +"</option>"; } if(init_prov !=undefined) province = province.replace(eval("/value=\'"+init_prov+"\'/"),"value='"+init_prov+"' selected"); }); $("select[name='province']").html(province); } //获取城市 function get_city(pid){ var city = first_option; var curr_prov = pid; $(_city_list).each(function(index){ if(curr_prov == _city_list[index].parent_id){ city = city + "<option value='" + _city_list[index].area_id + "'>"+ _city_list[index].area_name +"</option>"; } }); if(init_city !=undefined) city = city.replace(eval("/value=\'"+init_city+"\'/"),"value='"+init_city+"' selected"); $("select[name='city']").html(city); return true; } //获取区域 function get_area(cid){ var area = first_option; var curr_city = cid; $(_city_list).each(function(index){ if(curr_city == _city_list[index].parent_id){ area = area + "<option value='" + _city_list[index].area_id + "'>"+ _city_list[index].area_name +"</option>"; } }); if(init_area !=undefined) area = area.replace(eval("/value=\'"+init_area+"\'/"),"value='"+init_area+"' selected"); $("select[name='area']").html(area); return true; } });</script></body></html>
0 0
- 2015最新省市地区数据级联效果
- 实现省市级联效果
- 国省市县 ajax 地区级联动
- js版省市级联效果
- javascript实现省市级联效果
- JavaScript - 省市级联效果实例
- js 地区级联信息数据
- 省市二级级联json数据
- js 省市2级联动效果
- Jquery实现省市级联效果一
- 用js实现省市级联效果
- 省市级联--jquery调取json数据
- 省市级联
- 省市级联
- 省市级联
- 省市级联
- 省市级联
- 省市级联
- Objective C基础(六)---单例模式
- Linux-(15)YUM软件仓库
- linux防火墙和SELinux
- 黑马程序员IOS基础---C语言学习之流程控制
- HDU 4001--Dp--(第一道dp)
- 2015最新省市地区数据级联效果
- error: overloaded function with no contextual type information
- FTP文件上传与下载
- IDF2015现场报道:PMC展现高速IOPS方案
- 看电影网站合集
- mysql插入操作--插入中文的时候报错的解决方法
- 学会作笔记
- [学习笔记]Objective-C与C学习交接(3)
- HDU 1157