JS全国省市县三级联动代码完整版

合集下载

全国省市区三级联动js

全国省市区三级联动js
dsy.add("0_5_7",["榆次区","介休市","榆社县","箕城镇","左权县","辽阳镇","和顺县","义兴镇","昔阳县","乐平镇","寿阳县","朝阳镇","太谷县","明星镇","祁县","昭余镇","平遥县","古陶镇","灵石县","翠峰镇"]);
dsy.add("0_5_8",["尧都区","侯马市","霍州市","曲沃县","乐昌镇","翼城县","唐兴镇","襄汾县","新城镇","洪洞县","大槐树镇","古县","岳阳镇","安泽县","府城镇","浮山县","天坛镇","吉县","吉昌镇","乡宁县","昌宁镇","蒲县","蒲城镇","大宁县","昕水镇","永和县","芝河镇","隰县","龙泉镇","汾西县","永安镇"]);
dsy.add("0_4_7",["桃城区","冀州市","深州市","枣强县","枣强镇","武邑县","武邑镇","武强县","武强镇","饶阳县","饶阳镇","安平县","安平镇","故城县","郑口镇","景县","景州镇","阜城县","阜城镇"]);

省市联动代码

省市联动代码
测试页代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php+ajax动态生成下拉菜单</title>
<script language="JavaScript" src="../include/js/regions.js"></script>
{
$ra[area]=iconv('gb2312','UTF-8',$ra[area]);
echo "obja.options[obja.options.length] = new Option('".$ra[area]."','".$ra[area]."');\n";
$i++;
xmlHttp.send(null);
//setTimeout("startRequest()",2000);
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
xmlHttpa.onreadystatechange = handleStateChangearea;
document.getElementById('select2').options.length = 0;

Js做的城市三级联动,原创

Js做的城市三级联动,原创

Js做的城市三级联动,原创function setup(){for(i=1;i<=3;i++){document.getElementById(s[(i-1)]).onchange=new Function("chg("+(i)+")");}chg(0);}var a_t = new cn();a_t.add("0",["中国","韩国","台湾"]);a_t.add("0_0",["安徽","北京","福建","⽢肃","⼴东","⼴西","贵州","海南","河北","河南","⿊龙江","湖北","湖南","吉林","江苏","江西","辽宁","内蒙古","宁夏","青海","⼭东","⼭西"]); a_t.add("0_0_0",["安庆","蚌埠","巢湖","池州","滁州","⾩阳","合肥","淮北","淮南","黄⼭","六安","马鞍⼭","宿州","铜陵","芜湖","宣城","亳州"]);a_t.add("0_0_1",["北京"]);a_t.add("0_0_2",["福州","龙岩","南平","宁德","莆⽥","泉州","三明","厦门","漳州"]);a_t.add("0_0_3",["⽩银","定西","⽢南藏族⾃治州","嘉峪关","⾦昌","酒泉","兰州","临夏回族⾃治州","陇南","平凉","庆阳","天⽔","武威","张掖"]);a_t.add("0_0_4",["潮州","东莞","佛⼭","⼴州","河源","深圳","阳江","云浮","湛江","肇庆","中⼭","珠海"]);a_t.add("0_0_5",["百⾊","北海","崇左","防城港","桂林","贵港","河池","贺州","来宾","柳州","南宁","钦州","梧州","⽟林"]);a_t.add("0_0_6",["安顺","毕节","贵阳","六盘⽔","黔东南苗族侗族⾃治州","黔南布依族苗族⾃治州","黔西南布依族苗族⾃治州","铜仁","遵义"]);a_t.add("0_0_7",["澄迈县","定安县","东⽅","海⼝",,"琼中黎族苗族⾃治县","三亚","屯昌县","万宁","⽂昌","五指⼭","儋州"]);a_t.add("0_0_8",["保定","沧州","承德","邯郸","衡⽔","廊坊","秦皇岛","⽯家庄","唐⼭","邢台","张家⼝"]);a_t.add("0_0_9",["安阳","鹤壁","济源","焦作","开封","洛阳","南阳","平顶⼭","三门峡","商丘","新乡","信阳","许昌","郑州","周⼝","驻马店","漯河","濮阳"]);a_t.add("0_0_10",["⼤庆","⼤兴安岭","哈尔滨","鹤岗","⿊河","鸡西","佳⽊斯","牡丹江","七台河","齐齐哈尔","双鸭⼭","绥化","伊春"]);a_t.add("0_0_11",["鄂州","恩施⼟家族苗族⾃治州","黄冈","黄⽯","荆门","荆州","潜江","神农架林区","⼗堰","随州","天门","武汉","仙桃","咸宁","襄樊","孝感","宜昌"]);a_t.add("0_0_12",["常德","长沙","郴州","衡阳","怀化","娄底","邵阳","湘潭","湘西⼟家族苗族⾃治州","益阳","永州","岳阳","张家界","株洲"]);a_t.add("0_0_13",["⽩城","⽩⼭","长春","吉林","辽源","四平","松原","通化","延边朝鲜族⾃治州"]);a_t.add("0_0_14",["常州","淮安","连云港","南京","南通","苏州","宿迁","泰州","⽆锡","徐州","盐城","扬州","镇江"]);a_t.add("0_0_15",["抚州","赣州","吉安","景德镇","九江","南昌","萍乡","上饶","新余","宜春","鹰潭"]);a_t.add("0_0_16",["鞍⼭","本溪","朝阳","⼤连","丹东","抚顺","⾩新","葫芦岛","锦州","辽阳","盘锦","沈阳","铁岭","营⼝"]);a_t.add("0_0_17",["阿拉善盟","巴彦淖尔盟","包头","⾚峰","鄂尔多斯","呼和浩特","呼伦贝尔","通辽","乌海","乌兰察布盟","锡林郭勒盟","兴安盟"]);a_t.add("0_0_18",["固原","⽯嘴⼭","吴忠","银川"]);a_t.add("0_0_19",["果洛藏族⾃治州","海北藏族⾃治州","海东","海南藏族⾃治州","海西蒙古族藏族⾃治州","黄南藏族⾃治州","西宁","⽟树藏族⾃治州"]);a_t.add("0_0_20",["滨州","德州","东营","菏泽","济南","济宁","莱芜","聊城","临沂","青岛","⽇照","泰安","威海","潍坊","烟台","枣庄","淄博"]);a_t.add("0_1",["汉城特別市","釜⼭⼴域市","⼤邱⼴域市","济州道"]);a_t.add("0_1_0",["汉城"]);a_t.add("0_1_1",["釜⼭","机张郡"]);a_t.add("0_1_2",["⼤邱","达城郡"]);a_t.add("0_1_3",["仁川","江华郡","瓮津郡"]);a_t.add("0_1_4",["光州"]);a_t.add("0_1_5",["⼤⽥"]);a_t.add("0_1_6",["蔚⼭","蔚州郡"]);a_t.add("0_1_7",["⽔原市","城南市","安⼭市","⾼阳市","安养市","富川市"]);a_t.add("0_1_8",["春川市","原州市","江陵市"]);a_t.add("0_1_9",["清州市"]);a_t.add("0_1_10",["天安市"]);a_t.add("0_1_11",["全州市","群⼭市","益⼭市"]);a_t.add("0_1_12",["⽊浦市","丽⽔市","顺天市"]);a_t.add("0_1_13",["浦项市","龟尾市","庆州市"]);a_t.add("0_1_14",["昌原市","马⼭市","晋州市"]);a_t.add("0_1_15",["济州市","西归浦市","北济州郡","南济州郡"]);a_t.add("0_2",["基隆","台北","桃园","新⽵","苗栗","台中","彰化","南投","云林","嘉义","台南","⾼雄","台东","花莲"]);a_t.add("0_2_0",["基隆"]);a_t.add("0_2_1",["台北"]);a_t.add("0_2_2",["中壢市","平鎮市","⿓潭鄉","楊梅鎮","新屋鄉","觀⾳鄉","⿔⼭鄉","⼋德市","⼤溪鎮","復興鄉","⼤園鄉","蘆⽵鄉"]); a_t.add("0_2_3",["名古屋市 "]);a_t.add("0_2_4",["札幌市"]);a_t.add("0_2_5",["神戸市"]);a_t.add("0_2_6",["京都市"]);a_t.add("0_2_7",["福冈市"]);a_t.add("0_2_8",["川崎市"]);a_t.add("0_2_9",["埼⽟市"]);a_t.add("0_2_10",["⼴岛市"]);a_t.add("0_2_11",["仙台市"]);a_t.add("0_2_12",["北九州市 "]);a_t.add("0_2_13",["千叶市"]);//--></SCRIPT></head><body onLoad="setup()"><form method='post' action='@.php'><select id="tid1" name="tid1"></select><select id="tid2" name="tid2"></select><select id="tid3" name="tid3"></select><input type='submit' value='submit'></form>。

省市区三级联动(附j全国省市区json文件)

省市区三级联动(附j全国省市区json文件)
</div> <style>
label { display: inline-block; width:80px;
} #logisticPointForm div {
margin-top:10px; margin-bottom:10px; } </style> <script> $('#LatestDate').datetimebox({ required : true, onShowPanel:function(){
<div class="easyui-panel" style="padding:10px;"> <form id="logisticPointForm" method="post"> <div> <label>交接点:</label> <input class="easyui-textbox" id="PointName" name="PointName" data-options="required:true" style="width:70%;"> </div> <div> <label>选择区域:</label> <input class="easyui-combobox" id="Province" name="Province" style="width:22%" , data-options="prompt:'省',required:true,editable:false,"> <input class="easyui-combobox" id="City" name="City" style="width:22%" , data-options="prompt:'市',required:true,editable:false,"> <input class="easyui-combobox" id="County" name="County" style="width:22%" , data-options="prompt:'区/镇',required:true,editable:false,"> </div> <div> <label>详细地址:</label> <input class="easyui-textbox" id="Address" name="Address" data-options="required:true" style="width:70%;"> </div> <div> <label>对方物流员:</label> <input class="easyui-linkbutton" id="OppositeLogister" name="OppositeLogister" style="height:30px;" value="+选择物流员" onclick="sectionManageObj.choiceLogisterDialog(1)" /> <input id="OppositeLogisterId" name="OppositeLogisterId" type="hidden" /> </div> <div> <label>我方物流员:</label> <input class="easyui-linkbutton" id="MyLogister" name="MyLogister" style="height:30px;" value="+选择物流员" onclick="sectionManageObj.choiceLogisterDialog(2)"/> <input id="MyLogisterId" name="MyLogisterId" type="hidden"/> </div> <div> <label>最晚交接时间:</label> <!--<input class="easyui-datetimebox" id="LatestDate" name="LatestDate" style="width:30%" ,required:true, data-options="onShowPanel:function(){$(this).datetimebox('spinner').timespinner('setValue','00:00:00')}" >--> <input class="easyui-timespinner" id="LatestDate" name="LatestDate" required="required" data-options="width:'30%',showSeconds:true"> </div> <div style="text-align:center;"> <input href="#" class="easyui-linkbutton" value="取消" style="width:100px;height:30px;text-align:center;border-radius:5px;background:dimgray;color:white;" data-options="onClick:sectionManageObj.closeAddDialog <input href="#" class="easyui-linkbutton" value="确认" style="width:100px;height:30px;text-align:center;border-radius:5px;background:dodgerblue;color:white;" data-options="onClick:sectionManageObj.addSubmitDialog </div> </form>

JS实现省市三级联动

JS实现省市三级联动

JS实现省市三级联动做的东西需要写⼀个js三级联动,但是⼀时不⽌如何下⼿,加上如此多的省市信息,于是上⽹看了下⽹上的源码,发现千篇⼀律的样⼦,就随便拿了⼀个改了改,作参考。

顺便进⾏学习。

HTML 代码:1 <!DOCTYPE html>2 <html>34 <head>5 <meta charset="utf-8" />6 <title></title>7 </head>8 <script type="text/javascript" src="js/new_file.js"></script>910 <body>11 <select id="UserProvince" name="UserProvince"></select>12 <select id="UserCity" name="UserCity"></select>13 <select id="UserArea" name="UserArea"></select>14 <input type="text" value="详细地址" onblur="if(this.value=''){this.value='详细地址'}" onfocus="if(this.value='详细地址'){this.value='';this.style.color='#ff0000'}"> //onblur事件,当⿏标焦点离开时执⾏其⽅法,onfocus 事件在获得焦点时发⽣,也就1516 <script type="text/javascript">17 addressInit('UserProvince', 'UserCity', 'UserArea'); 地址初始化⽅法。

原生javascript制作省市区三级联动详细教程

原生javascript制作省市区三级联动详细教程

原生javascript制作省市区三级联动详细教程多级联动下拉菜单是前端常见的效果,省市区三级联动又属于其中最典型的案例。

多级联动一般都是与数据相关联的,根据数据来生成和修改联动的下拉菜单。

完成一个多级联动效果,有助于增强对数据处理的能力。

本实例以省市区三级联动为例,来说明具体是如何使用javascript 来关联数据,实现联动下拉菜单。

学习本教程之前,读者需要具备html和css技能,同时需要有简单的javascript基础。

这里先准备三个select元素,如下所示:<div class="select_wrap"><span>省:</span><select id="province"><option value="">请选择</option></select><span>市:</span><select id="city"><option value="">请选择</option></select><span>区/县:</span><select id="county"><option value="">请选择</option></select></div>再准备一些城市相关数据,本实例只列举了少量数量。

如下所示:var data = {"北京市": {"市辖区": ["东城区", "西城区", "朝阳区", "丰台区", "石景山区", "海淀区", "门头沟区", "房山区", "通州区", "顺义区", "昌平区", "大兴区", "怀柔区", "平谷区", "密云区", "延庆区"]},"河北省": {"石家庄市": ["长安区", "桥西区", "新华区", "井陉矿区", "裕华区", "藁城区", "鹿泉区", "栾城区", "井陉县", "正定县", "行唐县", "灵寿县", "高邑县", "深泽县", "赞皇县", "无极县", "平山县", "元氏县", "赵县", "石家庄高新技术产业开发区", "石家庄循环化工园区", "辛集市", "晋州市", "新乐市"],"唐山市": ["路南区", "路北区", "古冶区", "开平区", "丰南区", "丰润区", "曹妃甸区", "滦县", "滦南县", "乐亭县", "迁西县", "玉田县", "唐山市芦台经济技术开发区", "唐山市汉沽管理区", "唐山高新技术产业开发区", "河北唐山海港经济开发区", "遵化市", "迁安市"],"秦皇岛市": ["海港区", "山海关区", "北戴河区", "抚宁区", "青龙满族自治县", "昌黎县", "卢龙县", "秦皇岛市经济技术开发区", "北戴河新区"],"邯郸市": ["邯山区", "丛台区", "复兴区", "峰峰矿区", "肥乡区", "永年区", "临漳县", "成安县", "大名县", "涉县", "磁县", "邱县", "鸡泽县", "广平县", "馆陶县", "魏县", "曲周县", "邯郸经济技术开发区", "邯郸冀南新区", "武安市"],"衡水市": ["桃城区", "冀州区", "枣强县", "武邑县", "武强县", "饶阳县", "安平县", "故城县", "景县", "阜城县", "河北衡水经济开发区", "衡水滨湖新区", "深州市"]},"湖南省": {"长沙市": ["芙蓉区", "天心区", "岳麓区", "开福区", "雨花区", "望城区", "长沙县", "浏阳市", "宁乡市"],"株洲市": ["荷塘区", "芦淞区", "石峰区", "天元区", "株洲县", "攸县", "茶陵县", "炎陵县", "云龙示范区", "醴陵市"],"湘潭市": ["雨湖区", "岳塘区", "湘潭县", "湖南湘潭高新技术产业园区", "湘潭昭山示范区", "湘潭九华示范区", "湘乡市", "韶山市"],"衡阳市": ["珠晖区", "雁峰区", "石鼓区", "蒸湘区", "南岳区", "衡阳县", "衡南县", "衡山县", "衡东县", "祁东县", "衡阳综合保税区", "湖南衡阳高新技术产业园区", "湖南衡阳松木经济开发区", "耒阳市", "常宁市"],},"广东省": {"广州市": ["荔湾区", "越秀区", "海珠区", "天河区", "白云区", "黄埔区", "番禺区", "花都区", "南沙区", "从化区", "增城区"], "韶关市": ["武江区", "浈江区", "曲江区", "始兴县", "仁化县", "翁源县", "乳源瑶族自治县", "新丰县", "乐昌市", "南雄市"],"深圳市": ["罗湖区", "福田区", "南山区", "宝安区", "龙岗区", "盐田区", "龙华区", "坪山区"],"珠海市": ["香洲区", "斗门区", "金湾区"],}};PS:实际工作的数据一般由数据库提供。

用js实现省市县联动

用js实现省市县联动

用js实现省市县联动html文件<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""><html xmlns=""><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript" src="city.js"></script><title>js省市区三级联动-风羽</title></head><body onLoad="full_city();selectedValue()"><SELECT id=city1 onChange="eval('city_1('+this.value+')');eval('city_2('+document .all.city2.value+')');getCityValue();" name=city1><OPTION value="" selected>请选择</OPTION></SELECT><SELECT id=city2 onChange="eval('city_2('+this.value+')');getCityValue();"name=city2><OPTION value="" selected>请选择</OPTION></SELECT><SELECT id=city3 name=city3 onChange="getCityValue()"><OPTION value="" selected>请选择</OPTION></SELECT></body></html>js文件// JavaScript Documentvar city_data="";city_data="110000|北京市,110100|市辖区,110101|东城区,110102|西城区,110103|崇文区,110104|宣武区,110105|朝阳区,110106|丰台区,110107|石景山区,110108|海淀区,110109|门头沟区,110111|房山区,110112|通州区,110113|顺义区,110114|昌平区,110115|大兴区,110116|怀柔区,110117|平谷区,110200|县,110228|密云县,110229|延庆县,120000|天津市,120100|市辖区,120101|和平区,120102|河东区,120103|河西区,120104|南开区,120105|河北区,120106|红桥区,120107|塘沽区,120108|汉沽区,120109|大港区,120110|东丽区,120111|西青区,120112|津南区,120113|北辰区,120114|武清区,120115|宝坻区,120200|县,120221|宁河县,120223|静海县,120225|蓟县,130000|河北省,130100|石家庄市,130101|市辖区,130102|长安区,130103|桥东区,130104|桥西区,130105|新华区,130107|井陉矿区,130108|裕华区,130121|井陉县,130123|正定县,130124|栾城县,130125|行唐县,130126|灵寿县,130127|高邑县,130128|深泽县,130129|赞皇县,130130|无极县,130131|平山县,130132|元氏县,130133|赵县,130181|辛集市,130182|藁城市,130183|晋州市,130184|新乐市,130185|鹿泉市,130200|唐山市,130201|市辖区,130202|路南区,130203|路北区,130204|古冶区,130205|开平区,130207|丰南区,130208|丰润区,130223|滦县,130224|滦南县,130225|乐亭县,130227|迁西县,130229|玉田县,130230|唐海县,130281|遵化市,130283|迁安市,130300|秦皇岛市,130301|市辖区,130302|海港区,130303|山海关区,130304|北戴河区,130321|青龙满族自治县,130322|昌黎县,130323|抚宁县,130324|卢龙县,130400|邯郸市,130401|市辖区,130402|邯山区,130403|丛台区,130404|复兴区,130406|峰峰矿区,130421|邯郸县,130423|临漳县,130424|成安县,130425|大名县,130426|涉县,130427|磁县,130428|肥乡县,130429|永年县,130430|邱县,130431|鸡泽县,130432|广平县,130433|馆陶县,130434|魏县,130435|曲周县,130481|武安市,130500|邢台市,130501|市辖区,130502|桥东区,130503|桥西区,130521|邢台县,130522|临城县,130523|内丘县,130524|柏乡县,130525|隆尧县,130526|任县,130527|南和县,130528|宁晋县,130529|巨鹿县,130530|新河县,130531|广宗县,130532|平乡县,130533|威县,130534|清河县,130535|临西县,130581|南宫市,130582|沙河市,130600|保定市,130601|市辖区,130602|新市区,130603|北市区,130604|南市区,130621|满城县,130622|清苑县,130623|涞水县,130624|阜平县,130625|徐水县,130626|定兴县,130627|唐县,130628|高阳县,130629|容城县,130630|涞源县,130631|望都县,130632|安新县,130633|易县,130634|曲阳县,130635|蠡县,130636|顺平县,130637|博野县,130638|雄县,130681|涿州市,130682|定州市,130683|安国市,130684|高碑店市,130700|张家口市,130701|市辖区,130702|桥东区,130703|桥西区,130705|宣化区,130706|下花园区,130721|宣化县,130722|张北县,130723|康保县,130724|沽源县,130725|尚义县,130726|蔚县,130727|阳原县,130728|怀安县,130729|万全县,130730|怀来县,130731|涿鹿县,130732|赤城县,130733|崇礼县,130800|承德市,130801|市辖区,130802|双桥区,130803|双滦区,130804|鹰手营子矿区,130821|承德县,130822|兴隆县,130823|平泉县,130824|滦平县,130825|隆化县,130826|丰宁满族自治县,130827|宽城满族自治县,130828|围场满族蒙古族自治县,130900|沧州市,130901|市辖区,130902|新华区,130903|运河区,130921|沧县,130922|青县,130923|东光县,130924|海兴县,130925|盐山县,130926|肃宁县,130927|南皮县,130928|吴桥县,130929|献县,130930|孟村回族自治县,130981|泊头市,130982|任丘市,130983|黄骅市,130984|河间市,131000|廊坊市,131001|市辖区,131002|安次区,131003|广阳区,131022|固安县,131023|永清县,131024|香河县,131025|大城县,131026|文安县,131028|大厂回族自治县,131081|霸州市,131082|三河市,131100|衡水市,131101|市辖区,131102|桃城区,131121|枣强县,131122|武邑县,131123|武强县,131124|饶阳县,131125|安平县,131126|故城县,131127|景县,131128|阜城县,131181|冀州市,131182|深州市,140000|山西省,140100|太原市,140101|市辖区,140105|小店区,140106|迎泽区,140107|杏花岭区,140108|尖草坪区,140109|万柏林区,140110|晋源区,140121|清徐县,140122|阳曲县,140123|娄烦县,140181|古交市,140200|大同市,140201|市辖区,140202|城区,140203|矿区,140211|南郊区,140212|新荣区,140221|阳高县,140222|天镇县,140223|广灵县,140224|灵丘县,140225|浑源县,140226|左云县,140227|大同县,140300|阳泉市,140301|市辖区,140302|城区,140303|矿区,140311|郊区,140321|平定县,140322|盂县,140400|长治市,140401|市辖区,140402|城区,140411|郊区,140421|长治县,140423|襄垣县,140424|屯留县,140425|平顺县,140426|黎城县,140427|壶关县,140428|长子县,140429|武乡县,140430|沁县,140431|沁源县,140481|潞城市,140500|晋城市,140501|市辖区,140502|城区,140521|沁水县,140522|阳城县,140524|陵川县,140525|泽州县,140581|高平市,140600|朔州市,140601|市辖区,140602|朔城区,140603|平鲁区,140621|山阴县,140622|应县,140623|右玉县,140624|怀仁县,140700|晋中市,140701|市辖区,140702|榆次区,140721|榆社县,140722|左权县,140723|和顺县,140724|昔阳县,140725|寿阳县,140726|太谷县,140727|祁县,140728|平遥县,140729|灵石县,140781|介休市,140800|运城市,140801|市辖区,140802|盐湖区,140821|临猗县,140822|万荣县,140823|闻喜县,140824|稷山县,140825|新绛县,140826|绛县,140827|垣曲县,140828|夏县,140829|平陆县,140830|芮城县,140881|永济市,140882|河津市,140900|忻州市,140901|市辖区,140902|忻府区,140921|定襄县,140922|五台县,140923|代县,140924|繁峙县,140925|宁武县,140926|静乐县,140927|神池县,140928|五寨县,140929|岢岚县,140930|河曲县,140931|保德县,140932|偏关县,140981|原平市,141000|临汾市,141001|市辖区,141002|尧都区,141021|曲沃县,141022|翼城县,141023|襄汾县,141024|洪洞县,141025|古县,141026|安泽县,141027|浮山县,141028|吉县,141029|乡宁县,141030|大宁县,141031|隰县,141032|永和县,141033|蒲县,141034|汾西县,141081|侯马市,141082|霍州市,142300|吕梁地区,142301|孝义市,142302|离石市,142303|汾阳市,142322|文水县,142323|交城县,142325|兴县,142326|临县,142327|柳林县,142328|石楼县,142329|岚县,142330|方山县,142332|中阳县,142333|交口县,150000|内蒙古自治区,150100|呼和浩特市,150101|市辖区,150102|新城区,150103|回民区,150104|玉泉区,150105|赛罕区,150121|土默特左旗,150122|托克托县,150123|和林格尔县,150124|清水河县,150125|武川县,150200|包头市,150201|市辖区,150202|东河区,150203|昆都仑区,150204|青山区,150205|石拐区,150206|白云矿区,150207|九原区,150221|土默特右旗,150222|固阳县,150223|达尔罕茂明安联合旗,150300|乌海市,150301|市辖区,150302|海勃湾区,150303|海南区,150304|乌达区,150400|赤峰市,150401|市辖区,150402|红山区,150403|元宝山区,150404|松山区,150421|阿鲁科尔沁旗,150422|巴林左旗,150423|巴林右旗,150424|林西县,150425|克什克腾旗,150426|翁牛特旗,150428|喀喇沁旗,150429|宁城县,150430|敖汉旗,150500|通辽市,150501|市辖区,150502|科尔沁区,150521|科尔沁左翼中旗,150522|科尔沁左翼后旗,150523|开鲁县,150524|库伦旗,150525|奈曼旗,150526|扎鲁特旗,150581|霍林郭勒市,150600|鄂尔多斯市,150602|东胜区,150621|达拉特旗,150622|准格尔旗,150623|鄂托克前旗,150624|鄂托克旗,150625|杭锦旗,150626|乌审旗,150627|伊金霍洛旗,150700|呼伦贝尔市,150701|市辖区,150702|海拉尔区,150721|阿荣旗,150722|莫力达瓦达斡尔族自治旗,150723|鄂伦春自治旗,150724|鄂温克族自治旗,150725|陈巴尔虎旗,150726|新巴尔虎左旗,150727|新巴尔虎右旗,150781|满洲里市,150782|牙克石市,150783|扎兰屯市,150784|额尔古纳市,150785|根河市,152200|兴安盟,152201|乌兰浩特市,152202|阿尔山市,152221|科尔沁右翼前旗,152222|科尔沁右翼中旗,152223|扎赉特旗,152224|突泉县,152500|锡林郭勒盟,152501|二连浩特市,152502|锡林浩特市,152522|阿巴嘎旗,152523|苏尼特左旗,152524|苏尼特右旗,152525|东乌珠穆沁旗,152526|西乌珠穆沁旗,152527|太仆寺旗,152528|镶黄旗,152529|正镶白旗,152530|正蓝旗,152531|多伦县,152600|乌兰察布盟,152601|集宁市,152602|丰镇市,152624|卓资县,152625|化德县,152626|商都县,152627|兴和县,152629|凉城县,152630|察哈尔右翼前旗,152631|察哈尔右翼中旗,152632|察哈尔右翼后旗,152634|四子王旗,152800|巴彦淖尔盟,152801|临河市,152822|五原县,152823|磴口县,152824|乌拉特前旗,152825|乌拉特中旗,152826|乌拉特后旗,152827|杭锦后旗,152900|阿拉善盟,152921|阿拉善左旗,152922|阿拉善右旗,152923|额济纳旗,210000|辽宁省,210100|沈阳市,210101|市辖区,210102|和平区,210103|沈河区,210104|大东区,210105|皇姑区,210106|铁西区,210111|苏家屯区,210112|东陵区,210113|新城子区,210114|于洪区,210122|辽中县,210123|康平县,210124|法库县,210181|新民市,210200|大连市,210201|市辖区,210202|中山区,210203|西岗区,210204|沙河口区,210211|甘井子区,210212|旅顺口区,210213|金州区,210224|长海县,210281|瓦房店市,210282|普兰店市,210283|庄河市,210300|鞍山市,210301|市辖区,210302|铁东区,210303|铁西区,210304|立山区,210311|千山区,210321|台安县,210323|岫岩满族自治县,210381|海城市,210400|抚顺市,210401|市辖区,210402|新抚区,210403|东洲区,210404|望花区,210411|顺城区,210421|抚顺县,210422|新宾满族自治县,210423|清原满族自治县,210500|本溪市,210501|市辖区,210502|平山区,210503|溪湖区,210504|明山区,210505|南芬区,210521|本溪满族自治县,210522|桓仁满族自治县,210600|丹东市,210601|市辖区,210602|元宝区,210603|振兴区,210604|振安区,210624|宽甸满族自治县,210681|东港市,210682|凤城市,210700|锦州市,210701|市辖区,210702|古塔区,210703|凌河区,210711|太和区,210726|黑山县,210727|义县,210781|凌海市,210782|北宁市,210800|营口市,210801|市辖区,210802|站前区,210803|西市区,210804|鲅鱼圈区,210811|老边区,210881|盖州市,210882|大石桥市,210900|阜新市,210901|市辖区,210902|海州区,210903|新邱区,210904|太平区,210905|清河门区,210911|细河区,210921|阜新蒙古族自治县,210922|彰武县,211000|辽阳市,211001|市辖区,211002|白塔区,211003|文圣区,211004|宏伟区,211005|弓长岭区,211011|太子河区,211021|辽阳县,211081|灯塔市,211100|盘锦市,211101|市辖区,211102|双台子区,211103|兴隆台区,211121|大洼县,211122|盘山县,211200|铁岭市,211201|市辖区,211202|银州区,211204|清河区,211221|铁岭县,211223|西丰县,211224|昌图县,211281|调兵山市,211282|开原市,211300|朝阳市,211301|市辖区,211302|双塔区,211303|龙城区,211321|朝阳县,211322|建平县,211324|喀喇沁左翼蒙古族自治县,211381|北票市,211382|凌源市,211400|葫芦岛市,211401|市辖区,211402|连山区,211403|龙港区,211404|南票区,211421|绥中县,211422|建昌县,211481|兴城市,220000|吉林省,220100|长春市,220101|市辖区,220102|南关区,220103|宽城区,220104|朝阳区,220105|二道区,220106|绿园区,220112|双阳区,220122|农安县,220181|九台市,220182|榆树市,220183|德惠市,220200|吉林市,220201|市辖区,220202|昌邑区,220203|龙潭区,220204|船营区,220211|丰满区,220221|永吉县,220281|蛟河市,220282|桦甸市,220283|舒兰市,220284|磐石市,220300|四平市,220301|市辖区,220302|铁西区,220303|铁东区,220322|梨树县,220323|伊通满族自治县,220381|公主岭市,220382|双辽市,220400|辽源市,220401|市辖区,220402|龙山区,220403|西安区,220421|东丰县,220422|东辽县,220500|通化市,220501|市辖区,220502|东昌区,220503|二道江区,220521|通化县,220523|辉南县,220524|柳河县,220581|梅河口市,220582|集安市,220600|白山市,220601|市辖区,220602|八道江区,220621|抚松县,220622|靖宇县,220623|长白朝鲜族自治县,220625|江源县,220681|临江市,220700|松原市,220701|市辖区,220702|宁江区,220721|前郭尔罗斯蒙古族自治县,220722|长岭县,220723|乾安县,220724|扶余县,220800|白城市,220801|市辖区,220802|洮北区,220821|镇赉县,220822|通榆县,220881|洮南市,220882|大安市,222400|延边朝鲜族自治州,222401|延吉市,222402|图们市,222403|敦化市,222404|珲春市,222405|龙井市,222406|和龙市,222424|汪清县,222426|安图县,230000|黑龙江省,230100|哈尔滨市,230101|市辖区,230102|道里区,230103|南岗区,230104|道外区,230105|太平区,230106|香坊区,230107|动力区,230108|平房区,230121|呼兰县,230123|依兰县,230124|方正县,230125|宾县,230126|巴彦县,230127|木兰县,230128|通河县,230129|延寿县,230181|阿城市,230182|双城市,230183|尚志市,230184|五常市,230200|齐齐哈尔市,230201|市辖区,230202|龙沙区,230203|建华区,230204|铁锋区,230205|昂昂溪区,230206|富拉尔基区,230207|碾子山区,230208|梅里斯达斡尔族区,230221|龙江县,230223|依安县,230224|泰来县,230225|甘南县,230227|富裕县,230229|克山县,230230|克东县,230231|拜泉县,230281|讷河市,230300|鸡西市,230301|市辖区,230302|鸡冠区,230303|恒山区,230304|滴道区,230305|梨树区,230306|城子河区,230307|麻山区,230321|鸡东县,230381|虎林市,230382|密山市,230400|鹤岗市,230401|市辖区,230402|向阳区,230403|工农区,230404|南山区,230405|兴安区,230406|东山区,230407|兴山区,230421|萝北县,230422|绥滨县,230500|双鸭山市,230501|市辖区,230502|尖山区,230503|岭东区,230505|四方台区,230506|宝山区,230521|集贤县,230522|友谊县,230523|宝清县,230524|饶河县,230600|大庆市,230601|市辖区,230602|萨尔图区,230603|龙凤区,230604|让胡路区,230605|红岗区,230606|大同区,230621|肇州县,230622|肇源县,230623|林甸县,230624|杜尔伯特蒙古族自治县,230700|伊春市,230701|市辖区,230702|伊春区,230703|南岔区,230704|友好区,230705|西林区,230706|翠峦区,230707|新青区,230708|美溪区,230709|金山屯区,230710|五营区,230711|乌马河区,230712|汤旺河区,230713|带岭区,230714|乌伊岭区,230715|红星区,230716|上甘岭区,230722|嘉荫县,230781|铁力市,230800|佳木斯市,230801|市辖区,230802|永红区,230803|向阳区,230804|前进区,230805|东风区,230811|郊区,230822|桦南县,230826|桦川县,230828|汤原县,230833|抚远县,230881|同江市,230882|富锦市,230900|七台河市,230901|市辖区,230902|新兴区,230903|桃山区,230904|茄子河区,230921|勃利县,231000|牡丹江市,231001|市辖区,231002|东安区,231003|阳明区,231004|爱民区,231005|西安区,231024|东宁县,231025|林口县,231081|绥芬河市,231083|海林市,231084|宁安市,231085|穆棱市,231100|黑河市,231101|市辖区,231102|爱辉区,231121|嫩江县,231123|逊克县,231124|孙吴县,231181|北安市,231182|五大连池市,231200|绥化市,231201|市辖区,231202|北林区,231221|望奎县,231222|兰西县,231223|青冈县,231224|庆安县,231225|明水县,231226|绥棱县,231281|安达市,231282|肇东市,231283|海伦市,232700|大兴安岭地区,232721|呼玛县,232722|塔河县,232723|漠河县,310000|上海市,310100|市辖区,310101|黄浦区,310103|卢湾区,310104|徐汇区,310105|长宁区,310106|静安区,310107|普陀区,310108|闸北区,310109|虹口区,310110|杨浦区,310112|闵行区,310113|宝山区,310114|嘉定区,310115|浦东新区,310116|金山区,310117|松江区,310118|青浦区,310119|南汇区,310120|奉贤区,310200|县,310230|崇明县,320000|江苏省,320100|南京市,320101|市辖区,320102|玄武区,320103|白下区,320104|秦淮区,320105|建邺区,320106|鼓楼区,320107|下关区,320111|浦口区,320113|栖霞区,320114|雨花台区,320115|江宁区,320116|六合区,320124|溧水县,320125|高淳县,320200|无锡市,320201|市辖区,320202|崇安区,320203|南长区,320204|北塘区,320205|锡山区,320206|惠山区,320211|滨湖区,320281|江阴市,320282|宜兴市,320300|徐州市,320301|市辖区,320302|鼓楼区,320303|云龙区,320304|九里区,320305|贾汪区,320311|泉山区,320321|丰县,320322|沛县,320323|铜山县,320324|睢宁县,320381|新沂市,320382|邳州市,320400|常州市,320401|市辖区,320402|天宁区,320404|钟楼区,320405|戚墅堰区,320411|新北区,320412|武进区,320481|溧阳市,320482|金坛市,320500|苏州市,320501|市辖区,320502|沧浪区,320503|平江区,320504|金阊区,320505|虎丘区,320506|吴中区,320507|相城区,320581|常熟市,320582|张家港市,320583|昆山市,320584|吴江市,320585|太仓市,320600|南通市,320601|市辖区,320602|崇川区,320611|港闸区,320621|海安县,320623|如东县,320681|启东市,320682|如皋市,320683|通州市,320684|海门市,320700|连云港市,320701|市辖区,320703|连云区,320705|新浦区,320706|海州区,320721|赣榆县,320722|东海县,320723|灌云县,320724|灌南县,320800|淮安市,320801|市辖区,320802|清河区,320803|楚州区,320804|淮阴区,320811|清浦区,320826|涟水县,320829|洪泽县,320830|盱眙县,320831|金湖县,320900|盐城市,320901|市辖区,320902|城区,320921|响水县,320922|滨海县,320923|阜宁县,320924|射阳县,320925|建湖县,320928|盐都县,320981|东台市,320982|大丰市,321000|扬州市,321001|市辖区,321002|广陵区,321003|邗江区,321011|郊区,321023|宝应县,321081|仪征市,321084|高邮市,321088|江都市,321100|镇江市,321101|市辖区,321102|京口区,321111|润州区,321112|丹徒区,321181|丹阳市,321182|扬中市,321183|句容市,321200|泰州市,321201|市辖区,321202|海陵区,321203|高港区,321281|兴化市,321282|靖江市,321283|泰兴市,321284|姜堰市,321300|宿迁市,321301|市辖区,321302|宿城区,321321|宿豫县,321322|沭阳县,321323|泗阳县,321324|泗洪县,330000|浙江省,330100|杭州市,330101|市辖区,330102|上城区,330103|下城区,330104|江干区,330105|拱墅区,330106|西湖区,330108|滨江区,330109|萧山区,330110|余杭区,330122|桐庐县,330127|淳安县,330182|建德市,330183|富阳市,330185|临安市,330200|宁波市,330201|市辖区,330203|海曙区,330204|江东区,330205|江北区,330206|北仑区,330211|镇海区,330212|鄞州区,330225|象山县,330226|宁海县,330281|余姚市,330282|慈溪市,330283|奉化市,330300|温州市,330301|市辖区,330302|鹿城区,330303|龙湾区,330304|瓯海区,330322|洞头县,330324|永嘉县,330326|平阳县,330327|苍南县,330328|文成县,330329|泰顺县,330381|瑞安市,330382|乐清市,330400|嘉兴市,330401|市辖区,330402|秀城区,330411|秀洲区,330421|嘉善县,330424|海盐县,330481|海宁市,330482|平湖市,330483|桐乡市,330500|湖州市,330501|市辖区,330521|德清县,330522|长兴县,330523|安吉县,330600|绍兴市,330601|市辖区,330602|越城区,330621|绍兴县,330624|新昌县,330681|诸暨市,330682|上虞市,330683|嵊州市,330700|金华市,330701|市辖区,330702|婺城区,330703|金东区,330723|武义县,330726|浦江县,330727|磐安县,330781|兰溪市,330782|义乌市,330783|东阳市,330784|永康市,330800|衢州市,330801|市辖区,330802|柯城区,330803|衢江区,330822|常山县,330824|开化县,330825|龙游县,330881|江山市,330900|舟山市,330901|市辖区,330902|定海区,330903|普陀区,330921|岱山县,330922|嵊泗县,331000|台州市,331001|市辖区,331002|椒江区,331003|黄岩区,331004|路桥区,331021|玉环县,331022|三门县,331023|天台县,331024|仙居县,331081|温岭市,331082|临海市,331100|丽水市,331101|市辖区,331102|莲都区,331121|青田县,331122|缙云县,331123|遂昌县,331124|松阳县,331125|云和县,331126|庆元县,331127|景宁畲族自治县,331181|龙泉市,340000|安徽省,340100|合肥市,340101|市辖区,340102|瑶海区,340103|庐阳区,340104|蜀山区,340111|包河区,340121|长丰县,340122|肥东县,340123|肥西县,340200|芜湖市,340201|市辖区,340202|镜湖区,340203|马塘区,340204|新芜区,340207|鸠江区,340221|芜湖县,340222|繁昌县,340223|南陵县,340300|蚌埠市,340301|市辖区,340302|东市区,340303|中市区,340304|西市区,340311|郊区,340321|怀远县,340322|五河县,340323|固镇县,340400|淮南市,340401|市辖区,340402|大通区,340403|田家庵区,340404|谢家集区,340405|八公山区,340406|潘集区,340421|凤台县,340500|马鞍山市,340501|市辖区,340502|金家庄区,340503|花山区,340504|雨山区,340521|当涂县,340600|淮北市,340601|市辖区,340602|杜集区,340603|相山区,340604|烈山区,340621|濉溪县,340700|铜陵市,340701|市辖区,340702|铜官山区,340703|狮子山区,340711|郊区,340721|铜陵县,340800|安庆市,340801|市辖区,340802|迎江区,340803|大观区,340811|郊区,340822|怀宁县,340823|枞阳县,340824|潜山县,340825|太湖县,340826|宿松县,340827|望江县,340828|岳西县,340881|桐城市,341000|黄山市,341001|市辖区,341002|屯溪区,341003|黄山区,341004|徽州区,341021|歙县,341022|休宁县,341023|黟县,341024|祁门县,341100|滁州市,341101|市辖区,341102|琅琊区,341103|南谯区,341122|来安县,341124|全椒县,341125|定远县,341126|凤阳县,341181|天长市,341182|明光市,341200|阜阳市,341201|市辖区,341202|颍州区,341203|颍东区,341204|颍泉区,341221|临泉县,341222|太和县,341225|阜南县,341226|颍上县,341282|界首市,341300|宿州市,341301|市辖区,341302|墉桥区,341321|砀山县,341322|萧县,341323|灵璧县,341324|泗县,341400|巢湖市,341401|市辖区,341402|居巢区,341421|庐江县,341422|无为县,341423|含山县,341424|和县,341500|六安市,341501|市辖区,341502|金安区,341503|裕安区,341521|寿县,341522|霍邱县,341523|舒城县,341524|金寨县,341525|霍山县,341600|亳州市,341621|涡阳县,341622|蒙城县,341623|利辛县,341700|池州市,341701|市辖区,341702|贵池区,341721|东至县,341722|石台县,341723|青阳县,341800|宣城市,341801|市辖区,341802|宣州区,341821|郎溪县,341822|广德县,341823|泾县,341824|绩溪县,341825|旌德县,341881|宁国市,350000|福建省,350100|福州市,350101|市辖区,350102|鼓楼区,350103|台江区,350104|仓山区,350105|马尾区,350111|晋安区,350121|闽侯县,350122|连江县,350123|罗源县,350124|闽清县,350125|永泰县,350128|平潭县,350181|福清市,350182|长乐市,350200|厦门市,350201|市辖区,350202|鼓浪屿区,350203|思明区,350204|开元区,350205|杏林区,350206|湖里区,350211|集美区,350212|同安区,350300|莆田市,350301|市辖区,350302|城厢区,350303|涵江区,350304|荔城区,350305|秀屿区,350322|仙游县,350400|三明市,350401|市辖区,350402|梅列区,350403|三元区,350421|明溪县,350423|清流县,350424|宁化县,350425|大田县,350426|尤溪县,350427|沙县,350428|将乐县,350429|泰宁县,350430|建宁县,350481|永安市,350500|泉州市,350501|市辖区,350502|鲤城区,350503|丰泽区,350504|洛江区,350505|泉港区,350521|惠安县,350524|安溪县,350525|永春县,350526|德化县,350527|金门县,350581|石狮市,350582|晋江市,350583|南安市,350600|漳州市,350601|市辖区,350602|芗城区,350603|龙文区,350622|云霄县,350623|漳浦县,350624|诏安县,350625|长泰县,350626|东山县,350627|南靖县,350628|平和县,350629|华安县,350681|龙海市,350700|南平市,350701|市辖区,350702|延平区,350721|顺昌县,350722|浦城县,350723|光泽县,350724|松溪县,350725|政和县,350781|邵武市,350782|武夷山市,350783|建瓯市,350784|建阳市,350800|龙岩市,350801|市辖区,350802|新罗区,350821|长汀县,350822|永定县,350823|上杭县,350824|武平县,350825|连城县,350881|漳平市,350900|宁德市,350901|市辖区,350902|蕉城区,350921|霞浦县,350922|古田县,350923|屏南县,350924|寿宁县,350925|周宁县,350926|柘荣县,350981|福安市,350982|福鼎市,360000|江西省,360100|南昌市,360101|市辖区,360102|东湖区,360103|西湖区,360104|青云谱区,360105|湾里区,360111|青山湖区,360121|南昌县,360122|新建县,360123|安义县,360124|进贤县,360200|景德镇市,360201|市辖区,360202|昌江区,360203|珠山区,360222|浮梁县,360281|乐平市,360300|萍乡市,360301|市辖区,360302|安源区,360313|湘东区,360321|莲花县,360322|上栗县,360323|芦溪县,360400|九江市,360401|市辖区,360402|庐山区,360403|浔阳区,360421|九江县,360423|武宁县,360424|修水县,360425|永修县,360426|德安县,360427|星子县,360428|都昌县,360429|湖口县,360430|彭泽县,360481|瑞昌市,360500|新余市,360501|市辖区,360502|渝水区,360521|分宜县,360600|鹰潭市,360601|市辖区,360602|月湖区,360622|余江县,360681|贵溪市,360700|赣州市,360701|市辖区,360702|章贡区,360721|赣县,360722|信丰县,360723|大余县,360724|上犹县,360725|崇义县,360726|安远县,360727|龙南县,360728|定南县,360729|全南县,360730|宁都县,360731|于都县,360732|兴国县,360733|会昌县,360734|寻乌县,360735|石城县,360781|瑞金市,360782|南康市,360800|吉安市,360801|市辖区,360802|吉州区,360803|青原区,360821|吉安县,360822|吉水县,360823|峡江县,360824|新干县,360825|永丰县,360826|泰和县,360827|遂川县,360828|万安县,360829|安福县,360830|永新县,360881|井冈山市,360900|宜春市,360901|市辖区,360902|袁州区,360921|奉新县,360922|万载县,360923|上高县,360924|宜丰县,360925|靖安县,360926|铜鼓县,360981|丰城市,360982|樟树市,360983|高安市,361000|抚州市,361001|市辖区,361002|临川区,361021|南城县,361022|黎川县,361023|南丰县,361024|崇仁县,361025|乐安县,361026|宜黄县,361027|金溪县,361028|资溪县,361029|东乡县,361030|广昌县,361100|上饶市,361101|市辖区,361102|信州区,361121|上饶县,361122|广丰县,361123|玉山县,361124|铅山县,361125|横峰县,361126|弋阳县,361127|余干县,361128|波阳县,361129|万年县,361130|婺源县,361181|德兴市,370000|山东省,370100|济南市,370101|市辖区,370102|历下区,370103|市中区,370104|槐荫区,370105|天桥区,370112|历城区,370113|长清区,370124|平阴县,370125|济阳县,370126|商河县,370181|章丘市,370200|青岛市,370201|市辖区,370202|市南区,370203|市北区,370205|四方区,370211|黄岛区,370212|崂山区,370213|李沧区,370214|城阳区,370281|胶州市,370282|即墨市,370283|平度市,370284|胶南市,370285|莱西市,370300|淄博市,370301|市辖区,370302|淄川区,370303|张店区,370304|博山区,370305|临淄区,370306|周村区,370321|桓台县,370322|高青县,370323|沂源县,370400|枣庄市,370401|市辖区,370402|市中区,370403|薛城区,370404|峄城区,370405|台儿庄区,370406|山亭区,370481|滕州市,370500|东营市,370501|市辖区,370502|东营区,370503|河口区,370521|垦利县,370522|利津县,370523|广饶县,370600|烟台市,370601|市辖区,370602|芝罘区,370611|福山区,370612|牟平区,370613|莱山区,370634|长岛县,370681|龙口市,370682|莱阳市,370683|莱州市,370684|蓬莱市,370685|招远市,370686|栖霞市,370687|海阳市,370700|潍坊市,370701|市辖区,370702|潍城区,370703|寒亭区,370704|坊子区,370705|奎文区,370724|临朐县,370725|昌乐县,370781|青州市,370782|诸城市,370783|寿光市,370784|安丘市,370785|高密市,370786|昌邑市,370800|济宁市,370801|市辖区,370802|市中区,370811|任城区,370826|微山县,370827|鱼台县,370828|金乡县,370829|嘉祥县,370830|汶上县,370831|泗水县,370832|梁山县,370881|曲阜市,370882|兖州市,370883|邹城市,370900|泰安市,370901|市辖区,370902|泰山区,370903|岱岳区,370921|宁阳县,370923|东平县,370982|新泰市,370983|肥城市,371000|威海市,371001|市辖区,371002|环翠区,371081|文登市,371082|荣成市,371083|乳山市,371100|日照市,371101|市辖区,371102|东港区,371121|五莲县,371122|莒县,371200|莱芜市,371201|市辖区,371202|莱城区,371203|钢城区,371300|临沂市,371301|市辖区,371302|兰山区,371311|罗庄区,371312|河东区,371321|沂南县,371322|郯城县,371323|沂水县,371324|苍山县,371325|费县,371326|平邑县,371327|莒南县,371328|蒙阴县,371329|临沭县,371400|德州市,371401|市辖区,371402|德城区,371421|陵县,371422|宁津县,371423|庆云县,371424|临邑县,371425|齐河县,371426|平原县,371427|夏津县,371428|武城县,371481|乐陵市,371482|禹城市,371500|聊城市,371501|市辖区,371502|东昌府区,371521|阳谷县,371522|莘县,371523|茌平县,371524|东阿县,371525|冠县,371526|高唐县,371581|临清市,371600|滨州市,371601|市辖区,371602|滨城区,371621|惠民县,371622|阳信县,371623|无棣县,371624|沾化县,371625|博兴县,371626|邹平县,371700|荷泽市,371701|市辖区,371702|牡丹区,371721|曹县,371722|单县,371723|成武县,371724|巨野县,371725|郓城县,371726|鄄城县,371727|定陶县,371728|东明县,410000|河南省,410100|郑州市,410101|市辖区,410102|中原区,410103|二七区,410104|管城回族区,410105|金水区,410106|上街区,410108|邙山区,410122|中牟县,410181|巩义市,410182|荥阳市,410183|新密市,410184|新郑市,410185|登封市,410200|开封市,410201|市辖区,410202|龙亭区,410203|顺河回族区,410204|鼓楼区,410205|南关区,410211|郊区,410221|杞县,410222|通许县,410223|尉氏县,410224|开封县,410225|兰考县,410300|洛阳市,410301|市辖区,410302|老城区,410303|西工区,410304|廛河回族区,410305|涧西区,410306|吉利区,410307|洛龙区,410322|孟津县,410323|新安县,410324|栾川县,410325|嵩县,410326|汝阳县,410327|宜阳县,410328|洛宁县,410329|伊川县,410381|偃师市,410400|平顶山市,410401|市辖区,410402|新华区,410403|卫东区,410404|石龙区,410411|湛河区,410421|宝丰县,410422|叶县,410423|鲁山县,410425|郏县,410481|舞钢市,410482|汝州市,410500|安阳市,410501|市辖区,410502|文峰区,410503|北关区,410504|铁西区,410511|郊区,410522|安阳县,410523|汤阴县,410526|滑县,410527|内黄县,410581|林州市,410600|鹤壁市,410601|市辖区,410602|鹤山区,410603|山城区,410611|淇滨区,410621|浚县,410622|淇县,410700|新乡市,410701|市辖区,410702|红旗区,410703|新华区,410704|北站区,410711|郊区,410721|新乡县,410724|获嘉县,410725|原阳县,410726|延津县,410727|封丘县,410728|长垣县,410781|卫辉市,410782|辉县市,410800|焦作市,410801|市辖区,410802|解放区,410803|中站区,410804|马村区,410811|山阳区,410821|修武县,410822|博爱县,410823|武陟县,410825|温县,410881|济源市,410882|沁阳市,410883|孟州市,410900|濮阳市,410901|市辖区,410902|市区,410922|清丰县,410923|南乐县,410926|范县,410927|台前县,410928|濮阳县,411000|许昌市,411001|市辖区,411002|魏都区,411023|许昌县,411024|鄢陵县,411025|襄城县,411081|禹州市,411082|长葛市,411100|漯河市,411101|市辖区,411102|源汇区,411121|舞阳县,411122|临颍县,411123|郾城县,411200|三门峡市,411201|市辖区,411202|湖滨区,411221|渑池县,411222|陕县,411224|卢氏县,411281|义马市,411282|灵宝市,411300|南阳市,411301|市辖区,411302|宛城区,411303|卧龙区,411321|南召县,411322|方城县,411323|西峡县,411324|镇平县,411325|内乡县,411326|淅川县,411327|社旗县,411328|唐河县,411329|新野县,411330|桐柏县,411381|邓州市,411400|商丘市,411401|市辖区,411402|梁园区,411403|睢阳区,411421|民权县,411422|睢县,411423|宁陵县,411424|柘城县,411425|虞城县,411426|夏邑县,411481|永城市,411500|信阳市,411501|市辖区,411502|师河区,411503|平桥区,411521|罗山县,411522|光山县,411523|新县,411524|商城县,411525|固始县,411526|潢川县,411527|淮滨县,411528|息县,411600|周口市,411601|市辖区,411602|川汇区,411621|扶沟县,411622|西华县,411623|商水县,411624|沈丘县,411625|郸城县,411626|淮阳县,411627|太康县,411628|鹿邑县,411681|项城市,411700|驻马店市,411701|市辖区,411702|驿城区,411721|西平县,411722|上蔡县,411723|平舆县,411724|正阳县,411725|确山县,411726|泌阳县,411727|汝南县,411728|遂平县,411729|新蔡县,420000|湖北省,420100|武汉市,420101|市辖区,420102|江岸区,420103|江汉区,420104|乔口区,420105|汉阳区,420106|武昌区,420107|青山区,420111|洪山区,420112|东西湖区,420113|汉南区,420114|蔡甸区,420115|江夏区,420116|黄陂区,420117|新洲区,420200|黄石市,420201|市辖区,420202|黄石港区,420203|西塞山区,420204|下陆区,420205|铁山区,420222|阳新县,420281|大冶市,420300|十堰市,420301|市辖区,420302|茅箭区,420303|张湾区,420321|郧县,420322|郧西县,420323|竹山县,420324|竹溪县,420325|房县,420381|丹江口市,420500|宜昌市,420501|市辖区,420502|西陵区,420503|伍家岗区,420504|点军区,420505|虎亭区,420506|夷陵区,420525|远安县,420526|兴山县,420527|秭归县,420528|长阳土家族自治县,420529|五峰土家族自治县,420581|宜都市,420582|当阳市,420583|枝江市,420600|襄樊市,420601|市辖区,420602|襄城区,420606|樊城区,420607|襄阳区,420624|南漳县,420625|谷城县,420626|保康县,420682|老河口市,420683|枣阳市,420684|宜城市,420700|鄂州市,420701|市辖区,420702|梁子湖区,420703|华容区,420704|鄂城区,420800|荆门市,420801|市辖区,420802|东宝区,420804|掇刀区,420821|京山县,420822|沙洋县,420881|钟祥市,420900|孝感市,420901|市辖区,420902|孝南区,420921|孝昌县,420922|大悟县,420923|云梦县,420981|应城市,420982|安陆市,420984|汉川市,421000|荆州市,421001|市辖区,421002|沙市区,421003|荆州区,421022|公安县,421023|监利县,421024|江陵县,421081|石首市,421083|洪湖市,421087|松滋市,421100|黄冈市,421101|市辖区,421102|黄州区,421121|团风县,421122|红安县,421123|罗田县,421124|英山县,421125|浠水县,421126|蕲春县,421127|黄梅县,421181|麻城市,421182|武穴市,421200|咸宁市,421201|市辖区,421202|咸安区,421221|嘉鱼县,421222|通城县,421223|崇阳县,421224|通山县,421281|赤壁市,421300|随州市,421301|市辖区,421302|曾都区,421381|广水市,422800|恩施土家族苗族自治州,422801|恩施市,422802|利川市,422822|建始县,422823|巴东县,422825|宣恩县,422826|咸丰县,422827|来凤县,422828|鹤峰县,429000|省直辖行政单位,429004|仙桃市,429005|潜江市,429006|天门市,429021|神农架林区,430000|湖南省,430100|长沙市,430101|市辖区,430102|芙蓉区,430103|天心区,430104|岳麓区,430105|开福区,430111|雨花区,430121|长沙县,430122|望城县,430124|宁乡县,430181|浏阳市,430200|株洲市,430201|市辖区,430202|荷塘区,430203|芦淞区,430204|石峰区,430211|天元区,430221|株洲县,430223|攸县,430224|茶陵县,430225|炎陵县,430281|醴陵市,430300|湘潭市,430301|市辖区,430302|雨湖区,430304|岳塘区,430321|湘潭县,430381|湘乡市,430382|韶山市,430400|衡阳市,430401|市辖区,430405|珠晖区,430406|雁峰区,430407|石鼓区,430408|蒸湘区,430412|南岳区,430421|衡阳县,430422|衡南县,430423|衡山县,430424|衡东县,430426|祁东县,430481|耒阳市,430482|常宁市,430500|邵阳市,430501|市辖区,430502|双清区,430503|大祥区,430511|北塔区,430521|邵东县,430522|新邵县,430523|邵阳县,430524|隆回县,430525|洞口县,430527|绥宁县,430528|新宁县,430529|城步苗族自治县,430581|武冈市,430600|岳阳市,430601|市辖区,430602|岳阳楼区,430603|云溪区,430611|君山区,430621|岳阳县,430623|华容县,430624|湘阴县,430626|平江县,430681|汨罗市,430682|临湘市,430700|常德市,430701|市辖区,430702|武陵区,430703|鼎城区,430721|安乡县,430722|汉寿县,430723|澧县,430724|临澧县,430725|桃源县,430726|石门县,430781|津市市,430800|张家界市,430801|市辖区,430802|永定区,430811|武陵源区,430821|慈利县,430822|桑植县,430900|益阳市,430901|市辖区,430902|资阳区,430903|赫山区,430921|南县,430922|桃江县,430923|安化县,430981|沅江市,431000|郴州市,431001|市辖区,431002|北湖区,431003|苏仙区,431021|桂阳县,431022|宜章县,431023|永兴县,431024|嘉禾县,431025|临武县,431026|汝城县,431027|桂东县,431028|安仁县,431081|资兴市,431100|永州市,431101|市辖区,431102|芝山区,431103|冷水滩区,431121|祁阳县,431122|东安县,431123|双牌县,431124|道县,431125|江永县,431126|宁远县,431127|蓝山县,431128|新田县,431129|江华瑶族自治县,431200|怀化市,431201|市辖区,431202|鹤城区,431221|中方县,431222|沅陵县,431223|辰溪县,431224|溆浦县,431225|会同县,431226|麻阳苗族自治县,431227|新晃侗族自治县,431228|芷江侗族自治县,431229|靖州苗族侗族自治县,431230|通道侗族自治县,431281|洪江市,431300|娄底市,431301|市辖区,431302|娄星区,431321|双峰县,431322|新化县,431381|冷水江市,431382|涟源市,433100|湘西土家族苗族自治州,433101|吉首市,433122|泸溪县,433123|凤凰县,433124|花垣县,433125|保靖县,433126|古丈县,433127|永顺县,433130|龙山县,440000|广东省,440100|广州市,440101|市辖区,440102|东山区,440103|荔湾区,440104|越秀区,440105|海珠区,440106|天河区,440107|芳村区,440111|白云区,440112|黄埔区,440113|番禺区,440114|花都区,440183|增城市,440184|从化市,440200|韶关市,440201|市辖区,440202|北江区,440203|武江区,440204|浈江区,440221|曲江县,440222|始兴县,440224|仁化县,440229|翁源县,440232|乳源瑶族自治县,440233|新丰县,440281|乐昌市,440282|南雄市,440300|深圳市,440301|市辖区,440303|罗湖区,440304|福田区,440305|南山区,440306|宝安区,440307|龙岗区,440308|盐田区,440400|珠海市,440401|市辖区,440402|香洲区,440403|斗门区,440404|金湾区,440500|汕头市,440501|市辖区,440506|达濠区,440507|龙湖区,440508|金园区,440509|升平区,440510|河浦区,440523|南澳县,440582|潮阳市,440583|澄海市,440600|佛山市,440601|市辖区,440602|城区,440603|石湾区,440681|顺德市,440682|南海市,440683|三水市,440684|高明市,440700|江门市,440701|市辖区,440703|蓬江区,440704|江海区,440705|新会区,440781|台山市,440783|开平市,440784|鹤山市,440785|恩平市,440800|湛江市,440801|市辖区,440802|赤坎区,440803|霞山区,440804|坡头区,440811|麻章区,440823|遂溪县,440825|徐闻县,440881|廉江市,440882|雷州市,440883|吴川市,440900|茂名市,440901|市辖区,440902|茂南区,440903|茂港区,440923|电白县,440981|高州市,440982|化州市,440983|信宜市,441200|肇庆市,441201|市辖区,441202|端州区,441203|鼎湖区,441223|广宁县,441224|怀集县,441225|封开县,441226|德庆县,441283|高要市,441284|四会市,441300|惠州市,441301|市辖区,441302|惠城区,441322|博罗。

【示例代码及地区json】js省市区三级联动

【示例代码及地区json】js省市区三级联动

【⽰例代码及地区json】js省市区三级联动存在bug:1. 不能初始化市区,只能初始化省2. 当选择完毕市区之后,再改变省,区只能清空不可以初始化js代码:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title></head><body><select name="" id="Province"><option value="">请选择省</option></select><select name="" id="City"><option value="">请先选择省</option></select><select name="" id="District"><option value="">请先选择市</option></select><script src="area_data.js"></script><script>var Province,City,District;Province = document.getElementById("Province");City = document.getElementById("City");District = document.getElementById("District");// 初始化(function(){var ProvinceHtml = "";region.forEach(function(index){ProvinceHtml += "<option value='"+index.provinceCode+"'>"+index.provinceName+"</option>";});Province.innerHTML = ProvinceHtml;})()Province.onchange = function(){var that = this;var CityHtml = "";// 初始化县District.innerHTML = "<option value=''>请先选择市</option>";region.forEach(function(index){if(index.provinceCode == that.value){index.mallCityList.forEach(function(child){CityHtml += "<option value='"+child.cityCode+"'>"+child.cityName+"</option>";});City.innerHTML = CityHtml;return ;}});};City.onchange = function(){var that = this;var DistrictHtml = "";region.forEach(function(index){if(index.provinceCode == Province.value){index.mallCityList.forEach(function(child){if(child.cityCode == that.value){child.mallAreaList.forEach(function(sun){DistrictHtml += "<option value='"+sun.areaCode+"'>"+sun.areaName+"</option>";});District.innerHTML = DistrictHtml;return ;}});}});};</script></body></html>var region = [{"provinceCode": "110000","provinceName": "北京市","mallCityList": [{"cityCode": "110100","cityName": "北京市","mallAreaList": [{"areaCode": "110101", "areaName": "东城区" },{"areaCode": "110102", "areaName": "西城区" },{"areaCode": "110105", "areaName": "朝阳区" },{"areaCode": "110106", "areaName": "丰台区" },{"areaCode": "110107", "areaName": "⽯景⼭区" },{"areaCode": "110108", "areaName": "海淀区" },{"areaCode": "110109", "areaName": "门头沟区" },{"areaCode": "110111", "areaName": "房⼭区" },{"areaCode": "110112", "areaName": "通州区" },{"areaCode": "110113", "areaName": "顺义区" },{"areaCode": "110114", "areaName": "昌平区" },{"areaCode": "110115", "areaName": "⼤兴区" },{"areaCode": "110116", "areaName": "怀柔区" },{"areaCode": "110117", "areaName": "平⾕区" }]},{"cityCode": "110200","cityName": "北京市辖县","mallAreaList": [{"areaCode": "110228", "areaName": "密云县" },{"areaCode": "110229", "areaName": "延庆县" }]"provinceCode": "120000","provinceName": "天津市","mallCityList": [{"cityCode": "120100","cityName": "天津市","mallAreaList": [{"areaCode": "120101", "areaName": "和平区" },{"areaCode": "120102", "areaName": "河东区" },{"areaCode": "120103", "areaName": "河西区" },{"areaCode": "120104", "areaName": "南开区" },{"areaCode": "120105", "areaName": "河北区" },{"areaCode": "120106", "areaName": "红桥区" },{"areaCode": "120110", "areaName": "东丽区" },{"areaCode": "120111", "areaName": "西青区" },{"areaCode": "120112", "areaName": "津南区" },{"areaCode": "120113", "areaName": "北⾠区" },{"areaCode": "120114", "areaName": "武清区" },{"areaCode": "120115", "areaName": "宝坻区" },{"areaCode": "120116", "areaName": "滨海新区" }]},{"cityCode": "120200","cityName": "天津市辖县","mallAreaList": [{"areaCode": "120221", "areaName": "宁河县" },{"areaCode": "120223", "areaName": "静海县" },{"areaCode": "120225", "areaName": "蓟县"}]}]"mallCityList": [{"cityCode": "130100","cityName": "⽯家庄市","mallAreaList": [{"areaCode": "130102", "areaName": "长安区" },{"areaCode": "130104", "areaName": "桥西区" },{"areaCode": "130105", "areaName": "新华区" },{"areaCode": "130107", "areaName": "井陉矿区" },{"areaCode": "130108", "areaName": "裕华区" },{"areaCode": "130109", "areaName": "藁城区" },{"areaCode": "130110", "areaName": "⿅泉区" },{"areaCode": "130111", "areaName": "栾城区" },{"areaCode": "130121", "areaName": "井陉县" },{"areaCode": "130123", "areaName": "正定县" },{"areaCode": "130125", "areaName": "⾏唐县" },{"areaCode": "130126", "areaName": "灵寿县" },{"areaCode": "130127", "areaName": "⾼⾢县" },{"areaCode": "130128", "areaName": "深泽县" },{"areaCode": "130129", "areaName": "赞皇县" },{"areaCode": "130130", "areaName": "⽆极县" },{"areaCode": "130131", "areaName": "平⼭县" },{"areaCode": "130132", "areaName": "元⽒县" },{"areaCode": "130133", "areaName": "赵县"},{"areaCode": "130184", "areaName": "新乐市" }]},{"cityCode": "130200","cityName": "唐⼭市","mallAreaList": [{"areaCode": "130202", "areaName": "路南区" },{"areaCode": "130203", "areaName": "路北区" },{"areaCode": "130204", "areaName": "古冶区" },{"areaCode": "130205", "areaName": "开平区" },{"areaCode": "130207", "areaName": "丰南区" },{"areaCode": "130208", "areaName": "丰润区" },{"areaCode": "130209", "areaName": "曹妃甸区" },{"areaCode": "130223", "areaName": "滦县"},{"areaCode": "130224", "areaName": "滦南县" },{"areaCode": "130225", "areaName": "乐亭县" },{"areaCode": "130227", "areaName": "迁西县" },{"areaCode": "130229", "areaName": "⽟⽥县" },{"areaCode": "130281", "areaName": "遵化市" },{"areaCode": "130283", "areaName": "迁安市" }]},{"cityCode": "130300","cityName": "秦皇岛市","mallAreaList": [{"areaCode": "130302", "areaName": "海港区"},{"areaCode": "130321","areaName": "青龙满族⾃治县" },{"areaCode": "130322","areaName": "昌黎县"},{"areaCode": "130323","areaName": "抚宁县"},{"areaCode": "130324","areaName": "卢龙县"}]},{"cityCode": "130400","cityName": "邯郸市","mallAreaList": [{"areaCode": "130402","areaName": "邯⼭区"},{"areaCode": "130403","areaName": "丛台区"},{"areaCode": "130404","areaName": "复兴区"},{"areaCode": "130406","areaName": "峰峰矿区"},{"areaCode": "130421","areaName": "邯郸县"},{"areaCode": "130423","areaName": "临漳县"},{"areaCode": "130424","areaName": "成安县"},{"areaCode": "130425","areaName": "⼤名县"},{"areaCode": "130426","areaName": "涉县"},{"areaCode": "130427","areaName": "磁县"},{"areaCode": "130428","areaName": "肥乡县"},{"areaCode": "130429","areaName": "永年县"},{"areaCode": "130430","areaName": "邱县"},{"areaCode": "130432", "areaName": "⼴平县" },{"areaCode": "130433", "areaName": "馆陶县" },{"areaCode": "130434", "areaName": "魏县" },{"areaCode": "130435", "areaName": "曲周县" },{"areaCode": "130481", "areaName": "武安市" }]},{"cityCode": "130500","cityName": "邢台市","mallAreaList": [{"areaCode": "130502", "areaName": "桥东区" },{"areaCode": "130503", "areaName": "桥西区" },{"areaCode": "130521", "areaName": "邢台县" },{"areaCode": "130522", "areaName": "临城县" },{"areaCode": "130523", "areaName": "内丘县" },{"areaCode": "130524", "areaName": "柏乡县" },{"areaCode": "130525", "areaName": "隆尧县" },{"areaCode": "130526", "areaName": "任县" },{"areaCode": "130527", "areaName": "南和县" },{"areaCode": "130528", "areaName": "宁晋县" },{"areaCode": "130529", "areaName": "巨⿅县" },{"areaCode": "130530", "areaName": "新河县" },{"areaCode": "130531", "areaName": "⼴宗县" },{"areaCode": "130532", "areaName": "平乡县"},{"areaCode": "130534", "areaName": "清河县" },{"areaCode": "130535", "areaName": "临西县" },{"areaCode": "130581", "areaName": "南宫市" },{"areaCode": "130582", "areaName": "沙河市" }]},{"cityCode": "130600","cityName": "保定市","mallAreaList": [{"areaCode": "130602", "areaName": "新市区" },{"areaCode": "130603", "areaName": "北市区" },{"areaCode": "130604", "areaName": "南市区" },{"areaCode": "130621", "areaName": "满城县" },{"areaCode": "130622", "areaName": "清苑县" },{"areaCode": "130623", "areaName": "涞⽔县" },{"areaCode": "130624", "areaName": "⾩平县" },{"areaCode": "130625", "areaName": "徐⽔县" },{"areaCode": "130626", "areaName": "定兴县" },{"areaCode": "130627", "areaName": "唐县" },{"areaCode": "130628", "areaName": "⾼阳县" },{"areaCode": "130629", "areaName": "容城县" },{"areaCode": "130630", "areaName": "涞源县" },{"areaCode": "130631", "areaName": "望都县" },{"areaCode": "130633", "areaName": "易县"},{"areaCode": "130634", "areaName": "曲阳县" },{"areaCode": "130635", "areaName": "蠡县"},{"areaCode": "130636", "areaName": "顺平县" },{"areaCode": "130637", "areaName": "博野县" },{"areaCode": "130638", "areaName": "雄县"},{"areaCode": "130681", "areaName": "涿州市" },{"areaCode": "130682", "areaName": "定州市" },{"areaCode": "130683", "areaName": "安国市" },{"areaCode": "130684", "areaName": "⾼碑店市" }]},{"cityCode": "130700","cityName": "张家⼝市","mallAreaList": [{"areaCode": "130702", "areaName": "桥东区" },{"areaCode": "130703", "areaName": "桥西区" },{"areaCode": "130705", "areaName": "宣化区" },{"areaCode": "130706", "areaName": "下花园区" },{"areaCode": "130721", "areaName": "宣化县" },{"areaCode": "130722", "areaName": "张北县" },{"areaCode": "130723", "areaName": "康保县" },{"areaCode": "130724", "areaName": "沽源县" },{"areaCode": "130725", "areaName": "尚义县"},{"areaCode": "130727","areaName": "阳原县"},{"areaCode": "130728","areaName": "怀安县"},{"areaCode": "130729","areaName": "万全县"},{"areaCode": "130730","areaName": "怀来县"},{"areaCode": "130731","areaName": "涿⿅县"},{"areaCode": "130732","areaName": "⾚城县"},{"areaCode": "130733","areaName": "崇礼县"}]},{"cityCode": "130800","cityName": "承德市","mallAreaList": [{"areaCode": "130802","areaName": "双桥区"},{"areaCode": "130803","areaName": "双滦区"},{"areaCode": "130804","areaName": "鹰⼿营⼦矿区"},{"areaCode": "130821","areaName": "承德县"},{"areaCode": "130822","areaName": "兴隆县"},{"areaCode": "130823","areaName": "平泉县"},{"areaCode": "130824","areaName": "滦平县"},{"areaCode": "130825","areaName": "隆化县"},{"areaCode": "130826","areaName": "丰宁满族⾃治县"},{"areaCode": "130827","areaName": "宽城满族⾃治县"},{"areaCode": "130828","areaName": "围场满族蒙古族⾃治县" }]"mallAreaList": [{"areaCode": "130902","areaName": "新华区"},{"areaCode": "130903","areaName": "运河区"},{"areaCode": "130921","areaName": "沧县"},{"areaCode": "130922","areaName": "青县"},{"areaCode": "130923","areaName": "东光县"},{"areaCode": "130924","areaName": "海兴县"},{"areaCode": "130925","areaName": "盐⼭县"},{"areaCode": "130926","areaName": "肃宁县"},{"areaCode": "130927","areaName": "南⽪县"},{"areaCode": "130928","areaName": "吴桥县"},{"areaCode": "130929","areaName": "献县"},{"areaCode": "130930","areaName": "孟村回族⾃治县" },{"areaCode": "130981","areaName": "泊头市"},{"areaCode": "130982","areaName": "任丘市"},{"areaCode": "130983","areaName": "黄骅市"},{"areaCode": "130984","areaName": "河间市"}]},{"cityCode": "131000","cityName": "廊坊市","mallAreaList": [{"areaCode": "131002","areaName": "安次区"},{"areaCode": "131003","areaName": "⼴阳区"},{"areaCode": "131023","areaName": "永清县"},{"areaCode": "131024","areaName": "⾹河县"},{"areaCode": "131025","areaName": "⼤城县"},{"areaCode": "131026","areaName": "⽂安县"},{"areaCode": "131028","areaName": "⼤⼚回族⾃治县" },{"areaCode": "131081","areaName": "霸州市"},{"areaCode": "131082","areaName": "三河市"}]},{"cityCode": "131100","cityName": "衡⽔市","mallAreaList": [{"areaCode": "131102","areaName": "桃城区"},{"areaCode": "131121","areaName": "枣强县"},{"areaCode": "131122","areaName": "武⾢县"},{"areaCode": "131123","areaName": "武强县"},{"areaCode": "131124","areaName": "饶阳县"},{"areaCode": "131125","areaName": "安平县"},{"areaCode": "131126","areaName": "故城县"},{"areaCode": "131127","areaName": "景县"},{"areaCode": "131128","areaName": "⾩城县"},{"areaCode": "131181","areaName": "冀州市"},{"areaCode": "131182","areaName": "深州市"}]}]"mallCityList": [{"cityCode": "140100","cityName": "太原市","mallAreaList": [{"areaCode": "140105", "areaName": "⼩店区" },{"areaCode": "140106", "areaName": "迎泽区" },{"areaCode": "140107", "areaName": "杏花岭区" },{"areaCode": "140108", "areaName": "尖草坪区" },{"areaCode": "140109", "areaName": "万柏林区" },{"areaCode": "140110", "areaName": "晋源区" },{"areaCode": "140121", "areaName": "清徐县" },{"areaCode": "140122", "areaName": "阳曲县" },{"areaCode": "140123", "areaName": "娄烦县" },{"areaCode": "140181", "areaName": "古交市" }]},{"cityCode": "140200","cityName": "⼤同市","mallAreaList": [{"areaCode": "140202", "areaName": "城区"},{"areaCode": "140203", "areaName": "矿区"},{"areaCode": "140211", "areaName": "南郊区" },{"areaCode": "140212", "areaName": "新荣区" },{"areaCode": "140221", "areaName": "阳⾼县" },{"areaCode": "140222", "areaName": "天镇县" },{"areaCode": "140223", "areaName": "⼴灵县" },{"areaCode": "140226", "areaName": "左云县" },{"areaCode": "140227", "areaName": "⼤同县" }]},{"cityCode": "140300","cityName": "阳泉市","mallAreaList": [{"areaCode": "140302", "areaName": "城区" },{"areaCode": "140303", "areaName": "矿区" },{"areaCode": "140311", "areaName": "郊区" },{"areaCode": "140321", "areaName": "平定县" },{"areaCode": "140322", "areaName": "盂县" }]},{"cityCode": "140400","cityName": "长治市","mallAreaList": [{"areaCode": "140402", "areaName": "城区" },{"areaCode": "140411", "areaName": "郊区" },{"areaCode": "140421", "areaName": "长治县" },{"areaCode": "140423", "areaName": "襄垣县" },{"areaCode": "140424", "areaName": "屯留县" },{"areaCode": "140425", "areaName": "平顺县" },{"areaCode": "140426", "areaName": "黎城县" },{"areaCode": "140427", "areaName": "壶关县" },{"areaCode": "140428", "areaName": "长⼦县" },{"areaCode": "140431", "areaName": "沁源县" },{"areaCode": "140481", "areaName": "潞城市" }]},{"cityCode": "140500","cityName": "晋城市","mallAreaList": [{"areaCode": "140502", "areaName": "城区" },{"areaCode": "140521", "areaName": "沁⽔县" },{"areaCode": "140522", "areaName": "阳城县" },{"areaCode": "140524", "areaName": "陵川县" },{"areaCode": "140525", "areaName": "泽州县" },{"areaCode": "140581", "areaName": "⾼平市" }]},{"cityCode": "140600","cityName": "朔州市","mallAreaList": [{"areaCode": "140602", "areaName": "朔城区" },{"areaCode": "140603", "areaName": "平鲁区" },{"areaCode": "140621", "areaName": "⼭阴县" },{"areaCode": "140622", "areaName": "应县" },{"areaCode": "140623", "areaName": "右⽟县" },{"areaCode": "140624", "areaName": "怀仁县" }]},{"cityCode": "140700","cityName": "晋中市","mallAreaList": [{"areaCode": "140702", "areaName": "榆次区"。

JS实现省市县三级下拉联动

JS实现省市县三级下拉联动

JS实现省市县三级下拉联动纯JS实现省市县三级下拉联动,供⼤家参考,具体内容如下代码如下:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>省市县三级下拉联动-李康</title><style>fieldset{width: 25%;border: 1px dashed black;}legend{margin-left: 135px;}</style></head><body><form action=""><fieldset><legend>地址信息</legend>请选择居住地:<br><br><select id="province" οnchange="chooseProvince(this)"><option value="1">--请选择省--</option></select><select id="city" οnchange="chooseCity(this)"><option value="2">--请选择市--</option></select><select id="area"><option value="3">--请选择区--</option></select></fieldset></form><script>var provinceList = [{name: '北京',cityList: [{ name: '市辖区', areaList: ['东城区', '西城区', '崇⽂区', '宣武区', '朝阳区', '丰台区', '⽯景⼭区', '海淀区', '门头沟区', '房⼭区', '通州区', '顺义区', '昌平区', '⼤兴区', '怀柔区', '平⾕区'] }, { name: '县', areaList: ['密云县', '延庆县'] }]},{name: '河南',cityList: [{ name: '郑州市', areaList: ['市辖区', '中原区', '⼆七区', '管城回族区', '⾦⽔区', '上街区', '邙⼭区', '中牟县', '巩义市', '荥阳市', '新密市', '新郑市', '登封市'] },{ name: '开封市', areaList: ['市辖区', '龙亭区', '顺河回族区', '⿎楼区', '南关区', '郊 区', '杞 县', '通许县', '尉⽒县', '开封县', '兰考县'] },{ name: '洛阳市', areaList: ['市辖区', '⽼城区', '西⼯区', '廛河回族区', '涧西区', '吉利区', '洛龙区', '孟津县', '新安县', '栾川县', '嵩 县', '汝阳县', '宜阳县', '洛宁县', '伊川县', '偃师市'] }, { name: '新乡市', areaList: ['市辖区', '红旗区', '卫滨区', '凤泉区', '牧野区', '新乡县', '获嘉县', '原阳县', '延津县', '封丘县', '长垣县', '卫辉市', '辉县市'] },{ name: '焦作市', areaList: ['市辖区', '解放区', '中站区', '马村区', '⼭阳区', '修武县', '博爱县', '武陟县', '温 县', '济源市', '沁阳市', '孟州市'] }]},{name: '湖北',cityList: [{ name: '武汉市', areaList: ['市辖区', '江岸区', '江汉区', '乔⼝区', '汉阳区', '武昌区', '青⼭区', '洪⼭区', '东西湖区', '汉南区', '蔡甸区', '江夏区', '黄陂区', '新洲区'] },{ name: '黄⽯市', areaList: ['市辖区', '黄⽯港区', '西塞⼭区', '下陆区', '铁⼭区', '阳新县', '⼤冶市'] },{ name: '⼗堰市', areaList: ['市辖区', '茅箭区', '张湾区', '郧 县', '郧西县', '⽵⼭县', '⽵溪县', '房 县', '丹江⼝市'] }]}];var provinceArray = new Array();var cityArray = new Array();var areaArray = new Array();var provinceTag = document.getElementById("province");var cityTag = document.getElementById("city");var areaTag = document.getElementById("area");window.onload = function(){ //⽤window的onload事件,窗体加载完毕的时候var provinceTag = document.getElementById("province");var cityTag = document.getElementById("city");var areaTag = document.getElementById("area");for (var i = 0; i < provinceList.length; i++) {var province = provinceList[i]; //获取省var provinceName = ; //获取省名console.log(provinceName);provinceArray[i] = provinceName;provinceTag.add(new Option(provinceName, i));//通过Option⽅法将省名与下标对应,再将名字放到provinceTag中}}//建⽴省市之间的连接function chooseProvince(th) {var provinceTag = document.getElementById("province");var cityTag = document.getElementById("city");var areaTag = document.getElementById("area");var index = th.selectedIndex - 1; //“请选择省” 占了⼀个索引,所以需要减1var provinceName = provinceArray[index]; //获取省名for (var n = 0; n < provinceList.length; n++) {var provice = provinceList[n];console.log( == provinceName); //控制台打印⽅便观看if ( == provinceName) { //开始建⽴连接,通过if判断,前提是要满⾜if中的条件cityList = provice.cityList; //通过province的cityList获取城市列表cityTag.innerHTML = ""; //保证city为所选中的省的市console.log(cityList); //控制台打印for (var c = 0; c < cityList.length; c++) {var city = cityList[c]; //获取城市var cityName = ; //获取城市名cityArray[c] = cityName;cityTag.add(new Option(cityName, c)); //使⽤Option()⽅法获取每⼀个索引对应的数据,然后使⽤add()⽅法存⼊到数组中去,创建省市连接 }}}}// 建⽴市县之间的连接function chooseCity(ci) {var provinceTag = document.getElementById("province");var cityTag = document.getElementById("city");var areaTag = document.getElementById("area");var index = ci.selectedIndex;var cityName = cityArray[index];//获取城市名for (var j = 0; j < cityList.length; j++) {var city = cityList[j];//获取城市if ( == cityName) {var areaList = city.areaList;//县级列表数据areaTag.innerHTML = "";for (var k = 0; k < areaList.length; k++) {var area = areaList[k];//获取县areaTag.add(new Option(area, k));}}}}</script></body></html>效果如下如果⼤家还想深⼊学习,可以点击、进⾏学习。

JS全国省市县三级联动代码完整版

JS全国省市县三级联动代码完整版

全国省市县三级联动(数据完整版)网页前台代码:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Defaul t" EnableEventValidation="false"%><%@ Register assembly="AjaxControlToolkit"namespace="AjaxControlToolkit" tagprefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""/TR/xhtml 1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head runat="server"><title>发电机销售网点</title></head><body><form id="form1" runat="server"><div align="center"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><fieldset ><legend>全国省市县</legend><fieldset style="width: 265px"><legend>省</legend><asp:DropDownList ID="DropDownList1" runat="server"AutoPostBack="True"></asp:DropDownList><cc1:CascadingDropDown ID="DropDownList1_CascadingDropDown" runat="server"Category="provice" Enabled="True" LoadingText="读取数据中.." PromptText="请选择省"TargetControlID="DropDownList1" ServicePath="WebService.asmx" ServiceMethod ="GetproviceNames"></cc1:CascadingDropDown></fieldset><fieldset style="width: 266px"><legend>市</legend><asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"></asp:DropDownList><cc1:CascadingDropDown ID="DropDownList2_CascadingDropDown" runat="server"Category="city" Enabled="True" TargetControlID="DropDownList2" LoadingText="读取数据中.." PromptText="请选择市" ParentControlID="DropDownList1"ServicePath="WebService.asmx" ServiceMethod="GetCityNames"></cc1:CascadingDropDown></fieldset><fieldset style="width: 266px"><legend>县</legend><asp:DropDownList ID="DropDownList3" runat="server"></asp:DropDownList><cc1:CascadingDropDown ID="DropDownList3_CascadingDropDown" runat="server" Ca tegory="District" TargetControlID="DropDownList3"Enabled="True" LoadingText="读取数据中.." ParentControlID="DropDownList2"ServicePath="WebService.asmx" ServiceMethod="GetDistrictNames"></cc1:CascadingDropDown></fieldset></fieldset></div></form></body></html>WebService代码using System;using System.Collections;using System.Linq;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;using System.Xml.Linq;//访问数据库命名空间using System.Data;using System.Data.SqlClient;//访问web.config命名空间using System.Web.Configuration;//导入ScriptServiceAttribute类的命名空间using System.Web.Script.Services;//返回CascadingDropDownNameValue数组所需的命名空间using AjaxControlToolkit;using System.Collections.Generic;using System.Collections.Specialized;///<summary>///WebService 的摘要说明///</summary>[WebService(Namespace = "/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]//若要允许使用 AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。

省市联动js代码

省市联动js代码

省市联动js代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><title>JS实现的全国省份城市联动下拉菜单_⽹页代码站()</title></head><body><script language="javascript">cityareaname = new Array(35);cityareacode = new Array(35);function first(preP, preC, formname, selectP, selectC) {a = 0;if (selectP == '01'){ a = 1; tempoption = new Option('北京', '01', false, true); }else{ tempoption = new Option('北京', '01'); }eval('document.' + formname + '.' + preP + '.options[1]=tempoption;');cityareacode[0] = new Array('0101', '0102', '0103', '0104', '0105', '0106', '0107', '0108');cityareaname[0] = new Array('东城区', '西城区', '崇⽂区', '宣武区', '朝阳区', '海淀区', '丰台区', '⽯景⼭');if (selectP == '02'){ a = 2; tempoption = new Option('深圳', '02', false, true); }else{ tempoption = new Option('深圳', '02'); }eval('document.' + formname + '.' + preP + '.options[2]=tempoption;');cityareacode[1] = new Array('0201', '0202', '0203', '0204', '0205', '0206');cityareaname[1] = new Array('罗湖', '福⽥', '南⼭', '盐⽥', '宝安', '龙岗');if (selectP == '03'){ a = 3; tempoption = new Option('上海', '03', false, true); }else{ tempoption = new Option('上海', '03'); }eval('document.' + formname + '.' + preP + '.options[3]=tempoption;');cityareacode[2] = new Array('0301', '0302', '0303', '0304', '0305', '0306', '0307', '0308', '0309', '0310', '0311', '0312', '0313', '0314', '0315', '0316', '0317', '0318', '0319', '0320');cityareaname[2] = new Array('宝⼭', '⾦⼭', '南市', '长宁', '静安', '青浦', '崇明', '卢湾', '松江', '奉贤', '浦东', '杨浦', '虹⼝', '普陀', '闸北', '黄浦', '闵⾏', '徐汇', '嘉定', '南汇');if (selectP == '04'){ a = 4; tempoption = new Option('重庆', '04', false, true); }else{ tempoption = new Option('重庆', '04'); }eval('document.' + formname + '.' + preP + '.options[4]=tempoption;');cityareacode[3] = new Array('0401', '0402', '0403', '0404', '0405', '0406');cityareaname[3] = new Array('渝中', '江北', '沙坪坝', '南岸', '九龙坡', '⼤渡⼝');if (selectP == '05'){ a = 5; tempoption = new Option('天津', '05', false, true); }else{ tempoption = new Option('天津', '05'); }eval('document.' + formname + '.' + preP + '.options[5]=tempoption;');cityareacode[4] = new Array('0501', '0502', '0503', '0504', '0505', '0506', '0507', '0508', '0509', '0510', '0511', '0512', '0513', '0514', '0515'); cityareaname[4] = new Array('和平', '河北', '河西', '河东', '南开', '红桥', '塘沽', '汉沽', '⼤港', '东丽', '西青', '津南', '北⾠', '武清', '滨海');if (selectP == '06'){ a = 6; tempoption = new Option('⼴东', '06', false, true); }else{ tempoption = new Option('⼴东', '06'); }eval('document.' + formname + '.' + preP + '.options[6]=tempoption;');cityareacode[5] = new Array('0601', '0602', '0603', '0604', '0605', '0606', '0607', '0608', '0609', '0610', '0611', '0612', '0613', '0614', '0615'); cityareaname[5] = new Array('⼴州', '珠海', '中⼭', '佛⼭', '东莞', '清远', '肇庆', '阳江', '湛江', '韶关', '惠州', '河源', '汕尾', '汕头', '梅州');if (selectP == '07'){ a = 7; tempoption = new Option('河北', '07', false, true); }else{ tempoption = new Option('河北', '07'); }eval('document.' + formname + '.' + preP + '.options[7]=tempoption;');cityareacode[6] = new Array('0701', '0702', '0703', '0704', '0705', '0706', '0707', '0708', '0709', '0710', '0711');cityareaname[6] = new Array('⽯家庄', '唐⼭', '秦皇岛', '邯郸', '邢台', '张家⼝', '承德', '廊坊', '沧州', '保定', '衡⽔');if (selectP == '08'){ a = 8; tempoption = new Option('⼭西', '08', false, true); }else{ tempoption = new Option('⼭西', '08'); }eval('document.' + formname + '.' + preP + '.options[8]=tempoption;');cityareacode[7] = new Array('0801', '0802', '0803', '0804', '0805', '0806', '0807');cityareaname[7] = new Array('太原', '⼤同', '阳泉', '朔州', '长治', '临汾', '晋城');if (selectP == '09'){ a = 9; tempoption = new Option('内蒙古', '09', false, true); }else{ tempoption = new Option('内蒙古', '09'); }eval('document.' + formname + '.' + preP + '.options[9]=tempoption;');cityareacode[8] = new Array('0901', '0902', '0903', '0904', '0905', '0906', '0907', '0908', '0909', '0910', '0911');cityareaname[8] = new Array('呼和浩特', '包头', '乌海', '临河', '东胜', '集宁', '锡林浩特', '通辽', '⾚峰', '海拉尔', '乌兰浩特');if (selectP == '10'){ a = 10; tempoption = new Option('辽宁', '10', false, true); }else{ tempoption = new Option('辽宁', '10'); }eval('document.' + formname + '.' + preP + '.options[10]=tempoption;');cityareacode[9] = new Array('1001', '1002', '1003', '1004', '1005', '1006', '1007', '1008', '1009', '1010', '1011', '1012', '1013', '1014'); cityareaname[9] = new Array('沈阳', '⼤连', '鞍⼭', '锦州', '丹东', '盘锦', '铁岭', '抚顺', '营⼝', '辽阳', '⾩新', '本溪', '朝阳', '葫芦岛');if (selectP == '11'){ a = 11; tempoption = new Option('吉林', '11', false, true); }else{ tempoption = new Option('吉林', '11'); }eval('document.' + formname + '.' + preP + '.options[11]=tempoption;');cityareacode[10] = new Array('1101', '1102', '1103', '1104', '1105', '1106', '1107', '1108', '1109');cityareaname[10] = new Array('长春', '吉林', '四平', '辽源', '通化', '⽩⼭', '松原', '⽩城', '延边');if (selectP == '12'){ a = 12; tempoption = new Option('⿊龙江', '12', false, true); }else{ tempoption = new Option('⿊龙江', '12'); }eval('document.' + formname + '.' + preP + '.options[12]=tempoption;');cityareacode[11] = new Array('1201', '1202', '1203', '1204', '1205', '1206', '1207', '1208', '1209', '1210', '1211', '1212', '1213'); cityareaname[11] = new Array('哈尔滨', '齐齐哈尔', '牡丹江', '佳⽊斯', '⼤庆', '伊春', '⿊河', '鸡西', '鹤岗', '双鸭⼭', '七台河', '绥化', '⼤兴安岭'); if (selectP == '13'){ a = 13; tempoption = new Option('江苏', '13', false, true); }else{ tempoption = new Option('江苏', '13'); }eval('document.' + formname + '.' + preP + '.options[13]=tempoption;');cityareacode[12] = new Array('1301', '1302', '1303', '1304', '1305', '1306', '1307', '1308', '1309', '1310', '1311', '1312', '1313'); cityareaname[12] = new Array('南京', '苏州', '⽆锡', '常州', '镇江', '连云港 ', '扬州', '徐州 ', '南通', '盐城', '淮阴', '泰州', '宿迁');if (selectP == '14'){ a = 14; tempoption = new Option('浙江', '14', false, true); }else{ tempoption = new Option('浙江', '14'); }eval('document.' + formname + '.' + preP + '.options[14]=tempoption;');cityareacode[13] = new Array('1401', '1402', '1403', '1404', '1405', '1406', '1407', '1408', '1409', '1410', '1411');cityareaname[13] = new Array('杭州', '湖州', '丽⽔', '温州', '绍兴', '⾈⼭', '嘉兴', '⾦华', '台州', '衢州', '宁波');if (selectP == '15'){ a = 15; tempoption = new Option('安徽', '15', false, true); }else{ tempoption = new Option('安徽', '15'); }eval('document.' + formname + '.' + preP + '.options[15]=tempoption;');cityareacode[14] = new Array('1501', '1502', '1503', '1504', '1505', '1506', '1507', '1508', '1509', '1510', '1511', '1512', '1513', '1514', '1515', '1516', '1517');cityareaname[14] = new Array('合肥 ', '芜湖 ', '蚌埠 ', '滁州 ', '安庆 ', '六安 ', '黄⼭ ', '宣城 ', '淮南 ', '宿州 ', '马鞍⼭ ', '铜陵', '淮北 ', '⾩阳 ', '池州 ', '巢湖 ', '亳州');if (selectP == '16'){ a = 16; tempoption = new Option('福建', '16', false, true); }else{ tempoption = new Option('福建', '16'); }eval('document.' + formname + '.' + preP + '.options[16]=tempoption;');cityareacode[15] = new Array('1601', '1602', '1603', '1604', '1605', '1606', '1607', '1608', '1609');cityareaname[15] = new Array('福州 ', '厦门 ', '泉州 ', '漳州 ', '龙岩 ', '南平 ', '宁德 ', '莆⽥ ', '三明');if (selectP == '17'){ a = 17; tempoption = new Option('江西', '17', false, true); }else{ tempoption = new Option('江西', '17'); }eval('document.' + formname + '.' + preP + '.options[17]=tempoption;');cityareacode[16] = new Array('1701', '1702', '1703', '1704', '1705', '1706', '1707', '1708', '1709', '1710', '1711');cityareaname[16] = new Array('南昌', '景德镇', '九江', '萍乡', '新余', '鹰潭', '赣州', '宜春', '吉安', '上饶', '抚州');if (selectP == '18'){ a = 18; tempoption = new Option('⼭东', '18', false, true); }else{ tempoption = new Option('⼭东', '18'); }eval('document.' + formname + '.' + preP + '.options[18]=tempoption;');cityareacode[17] = new Array('1801', '1802', '1803', '1804', '1805', '1806', '1807', '1808', '1809', '1810', '1811', '1812', '1813', '1814', '1815', '1816', '1817');cityareaname[17] = new Array('济南', '青岛', '淄博', '德州', '烟台', '潍坊', '济宁', '泰安', '临沂', '菏泽', '威海', '枣庄', '⽇照', '莱芜', '聊城', '滨州', '东营');if (selectP == '19'){ a = 19; tempoption = new Option('河南', '19', false, true); }else{ tempoption = new Option('河南', '19'); }eval('document.' + formname + '.' + preP + '.options[19]=tempoption;');cityareacode[18] = new Array('1901', '1902', '1903', '1904', '1905', '1906', '1907', '1908', '1909', '1910', '1911', '1912', '1913', '1914', '1915', '1916', '1917', '1918');cityareaname[18] = new Array('郑州', '开封', '洛阳', '平顶⼭', '安阳', '鹤壁', '新乡', '焦作', '濮阳', '许昌', '漯河', '三门峡', '南阳', '商丘', '周⼝', '驻马店', '信阳', '济源');if (selectP == '20'){ a = 20; tempoption = new Option('湖北', '20', false, true); }else{ tempoption = new Option('湖北', '20'); }eval('document.' + formname + '.' + preP + '.options[20]=tempoption;');cityareacode[19] = new Array('2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017');cityareaname[19] = new Array('武汉', '黄⽯', '⼗堰', '荆州', '宜昌', '襄樊', '鄂州', '荆门', '孝感', '黄冈', '咸宁', '恩施', '随州', '仙桃', '天门', '潜江', '神农架');if (selectP == '21'){ a = 21; tempoption = new Option('湖南', '21', false, true); }else{ tempoption = new Option('湖南', '21'); }eval('document.' + formname + '.' + preP + '.options[21]=tempoption;');cityareacode[20] = new Array('2101', '2102', '2103', '2104', '2105', '2106', '2107', '2108', '2109', '2110', '2111', '2112', '2113'); cityareaname[20] = new Array('长沙', '株州', '湘潭', '衡阳', '邵阳', '岳阳', '常德', '郴州', '益阳', '永州', '怀化', '娄底', '湘西 ');if (selectP == '22'){ a = 22; tempoption = new Option('⼴西', '22', false, true); }else{ tempoption = new Option('⼴西', '22'); }eval('document.' + formname + '.' + preP + '.options[22]=tempoption;');cityareacode[21] = new Array('2201', '2202', '2203', '2204', '2205', '2206', '2207', '2208', '2209', '2210', '2211', '2212');cityareaname[21] = new Array('南宁', '柳州', '桂林', '梧州', '北海', '防城港', '钦州', '贵港', '⽟林', '贺州', '百⾊', '河池');if (selectP == '23'){ a = 23; tempoption = new Option('海南', '23', false, true); }else{ tempoption = new Option('海南', '23'); }eval('document.' + formname + '.' + preP + '.options[23]=tempoption;');cityareacode[22] = new Array('2301', '2302', '2303', '2304', '2305', '2306', '2307', '2308', '2309');cityareaname[22] = new Array('海⼝ ', '三亚', '通什', '琼海', '琼⼭', '⽂昌', '万宁', '东⽅', '儋州');if (selectP == '24'){ a = 24; tempoption = new Option('四川', '24', false, true); }else{ tempoption = new Option('四川', '24'); }eval('document.' + formname + '.' + preP + '.options[24]=tempoption;');cityareacode[23] = new Array('2401', '2402', '2403', '2404', '2405', '2406', '2407', '2408', '2409', '2410', '2411', '2412', '2413', '2414', '2415', '2416', '2417', '2418', '2419', '2420');cityareaname[23] = new Array('成都', '⾃贡', '攀枝花', '泸州', '德阳', '绵阳', '⼴元', '遂宁', '内江', '乐⼭', '南充 ', '宜宾', '⼴安', '达川', '巴中', '雅安', '眉⼭ ', '阿坝 ', '⽢孜 ', '凉⼭ ');if (selectP == '25'){ a = 25; tempoption = new Option('贵州', '25', false, true); }else{ tempoption = new Option('贵州', '25'); }eval('document.' + formname + '.' + preP + '.options[25]=tempoption;');cityareacode[24] = new Array('2501', '2502', '2503', '2504', '2505', '2506', '2507', '2508', '2509');cityareaname[24] = new Array('贵阳 ', '六盘⽔', '遵义', '铜仁', '毕节', '安顺', '黔西南 ', '黔东南', '黔南');if (selectP == '26'){ a = 26; tempoption = new Option('云南', '26', false, true); }else{ tempoption = new Option('云南', '26'); }eval('document.' + formname + '.' + preP + '.options[26]=tempoption;');cityareacode[25] = new Array('2601', '2602', '2603', '2604', '2605', '2606', '2607', '2608', '2609', '2610', '2611', '2612', '2613', '2614', '2615', '2616', '2617');cityareaname[25] = new Array('昆明', '东川', '曲靖', '⽟溪', '昭通', '思茅', '临沧', '保⼭', '丽江', '⽂⼭ ', '红河 ', '西双版纳 ', '楚雄 ', '⼤理 ', '德宏 ', '怒江', '迪庆');if (selectP == '27'){ a = 27; tempoption = new Option('西藏', '27', false, true); }else{ tempoption = new Option('西藏', '27'); }eval('document.' + formname + '.' + preP + '.options[27]=tempoption;');cityareacode[26] = new Array('2701', '2702', '2703', '2704', '2705', '2706', '2707');cityareaname[26] = new Array('拉萨', '那曲', '昌都', '⼭南', '⽇喀则', '阿⾥', '林芝');if (selectP == '28'){ a = 28; tempoption = new Option('陕西', '28', false, true); }else{ tempoption = new Option('陕西', '28'); }eval('document.' + formname + '.' + preP + '.options[28]=tempoption;');cityareacode[27] = new Array('2801', '2802', '2803', '2804', '2805', '2806', '2807', '2808', '2809', '2810');cityareaname[27] = new Array('西安', '铜川', '宝鸡', '咸阳', '渭南', '延安', '汉中', '榆林', '商洛', '安康');if (selectP == '29'){ a = 29; tempoption = new Option('⽢肃', '29', false, true); }else{ tempoption = new Option('⽢肃', '29'); }eval('document.' + formname + '.' + preP + '.options[29]=tempoption;');cityareacode[28] = new Array('2901', '2902', '2903', '2904', '2905', '2906', '2907', '2908', '2909', '2910', '2911', '2912', '2913', '2914'); cityareaname[28] = new Array('兰州', '⾦昌', '⽩银', '天⽔', '嘉峪关', '定西', '平凉', '庆阳', '陇南', '武威', '张掖', '酒泉', '⽢南 ', '临夏');if (selectP == '30'){ a = 30; tempoption = new Option('青海', '30', false, true); }else{ tempoption = new Option('青海', '30'); }eval('document.' + formname + '.' + preP + '.options[30]=tempoption;');cityareacode[29] = new Array('3001', '3002', '3003', '3004', '3005', '3006', '3007', '3008');cityareaname[29] = new Array('西宁', '海东', ' 海北 ', '黄南', '海南', '果洛', '⽟树', '海西');if (selectP == '31'){ a = 31; tempoption = new Option('宁夏', '31', false, true); }else{ tempoption = new Option('宁夏', '31'); }eval('document.' + formname + '.' + preP + '.options[31]=tempoption;');cityareacode[30] = new Array('3101', '3102', '3103', '3104');cityareaname[30] = new Array('银川', '⽯嘴⼭', '银南', '固原');if (selectP == '32'){ a = 32; tempoption = new Option('新疆', '32', false, true); }else{ tempoption = new Option('新疆', '32'); }eval('document.' + formname + '.' + preP + '.options[32]=tempoption;');cityareacode[31] = new Array('3201', '3202', '3203', '3204', '3205', '3206', '3207', '3208', '3209', '3210', '3211', '3212', '3213'); cityareaname[31] = new Array('乌鲁⽊齐', '克拉玛依', '⽯河⼦', '吐鲁番', '哈密', '和⽥', '阿克苏', '喀什', '克孜勒苏', '巴⾳郭楞', '昌吉', '博尔塔拉', '伊犁');if (selectP == '33'){ a = 33; tempoption = new Option('⾹港', '33', false, true); }else{ tempoption = new Option('⾹港', '33'); }eval('document.' + formname + '.' + preP + '.options[33]=tempoption;');cityareacode[32] = new Array();cityareaname[32] = new Array();if (selectP == '34'){ a = 34; tempoption = new Option('澳门', '34', false, true); }else{ tempoption = new Option('澳门', '34'); }eval('document.' + formname + '.' + preP + '.options[34]=tempoption;');cityareacode[33] = new Array();cityareaname[33] = new Array();if (selectP == '35'){ a = 35; tempoption = new Option('台湾', '35', false, true); }else{ tempoption = new Option('台湾', '35'); }eval('document.' + formname + '.' + preP + '.options[35]=tempoption;');cityareacode[34] = new Array();cityareaname[34] = new Array();eval('document.' + formname + '.' + preP + '.options[a].selected=true;');cityid = selectP;if (cityid != '0') {b = 0; for (i = 0; i < cityareaname[cityid - 1].length; i++) {if (selectC == cityareacode[cityid - 1][i]){ b = i + 1; tempoption = new Option(cityareaname[cityid - 1][i], cityareacode[cityid - 1][i], false, true); }elsetempoption = new Option(cityareaname[cityid - 1][i], cityareacode[cityid - 1][i]);eval('document.' + formname + '.' + preC + '.options[i+1]=tempoption;');}eval('document.' + formname + '.' + preC + '.options[b].selected=true;');}}function selectcityarea(preP, preC, formname) {cityid = eval('document.' + formname + '.' + preP + '.selectedIndex;');j = eval('document.' + formname + '.' + preC + '.length;');for (i = 1; i < j; i++){ eval('document.' + formname + '.' + preC + '.options[j-i]=null;') }if (cityid != "0") {for (i = 0; i < cityareaname[cityid - 1].length; i++) {tempoption = new Option(cityareaname[cityid - 1][i], cityareacode[cityid - 1][i]);eval('document.' + formname + '.' + preC + '.options[i+1]=tempoption;');}}}</script><form action="file:///C|/Program%20Files/Macromedia/Dreamweaver%204/Lessons/Lesson%20Files/info_search.asp?martid=" method="post" name="form1"><img alt="" src="file:///C|/Program%20Files/Macromedia/Dreamweaver%204/images/w_KT.gif"height="6" width="1" /><br /><table width="300" border="0" cellspacing="0" cellpadding="1" bgcolor="#FFFDE6"><tr><td class="black_con9" align="right">省份:</td><td class="black_con9"><select name="selectp" onchange="selectcityarea('selectp','selectc','form1');"><option value="0" selected="selected">不限-- </option></select></td></tr><tr><td class="black_con9" align="right">县/市:</td><td class="black_con9"><select name="selectc"><option value="0" selected="selected">不限-- </option></select></td></tr></table></form><script language="javascript">first("selectp", "selectc", "form1", 0, 0);</script><br /><p><a href="">⽹页代码站</a> - 最专业的⽹页代码下载⽹站 - 致⼒为中国站长提供有质量的⽹页代码!</p> </body></html>。

JavaScript实现省市区三级联动

JavaScript实现省市区三级联动

JavaScript实现省市区三级联动本⽂实例为⼤家分享了JavaScript实现省市区三级联动的具体代码,供⼤家参考,具体内容如下⾸先是js$(document).ready(function(){getErpMarketByParentCode(0,'province',province);getErpMarketByParentCode(province,'city',city);getErpMarketByParentCode(city,'area',area);getErpMarketByParentCode(area,'market',market);$('#city').append($('<option>').val('').html('-请选择-')).val('');$('#area').append($('<option>').val('').html('-请选择-')).val('');if($('#market')){$('#market').append($('<option>').val('').html('-请选择-')).val('');}$('#province').change(function(){if($(this).val() == ''){ // 请选择$('#city').empty();$('#area').empty();$('#city').append($('<option>').val('').html('-请选择-')).val('');$('#area').append($('<option>').val('').html('-请选择-')).val('');if($('#market')){$('#market').empty();$('#market').append($('<option>').val('').html('-请选择-')).val('');}return;}getErpMarketByParentCode($(this).val(),'city');$('#area').empty();$('#area').append($('<option>').val('').html('-请选择-')).val('');});$('#city').change(function(){getErpMarketByParentCode($(this).val(),'area');if($('#market')){$('#market').empty();$('#market').append($('<option>').val('').html('-请选择-')).val('');}});$('#area').change(function(){getErpMarketByParentCode($(this).val(),'market');});});function getErpMarketByParentCode(parentCode, id, value){$.ajax({url:'/getErpMarketByParentCode',type:'post',data:{code:parentCode},dataType : 'json',error:function(){alert('error');},success:function(data){var select = $('#' + id);if(select){select.empty();select.append($('<option>').val('').html('-请选择-'));$.each(data.erpMarketList,function(i, erpMarket){select.append($('<option>').val(erpMarket.code).html());});select.val(value);}}});}然后是后台⽅法@RequestMapping(value = "/getErpMarketByParentCode")public ModelAndView getErpMarketByParentCode(HttpServletRequest request, HttpServletResponse response) throws Exception { String code = request.getParameter("code");List<ErpMarket> erpMarketList = erpMarketService.getErpMarketListByParentCode(code);JSONObject jsonObject = new JSONObject();jsonObject.put("erpMarketList",erpMarketList);response.getWriter().write(jsonObject.toString());return null;}service⽅法,是从内从中获取省市区这张表public List<ErpMarket> getErpMarketListByParentCode(String parentCode){Hashtable erpMarketTable = LoadOnStartService.erpMarketTable;//从内存中获取这张表List<ErpMarket> erpMarketList = new ArrayList<ErpMarket>();Iterator its = erpMarketTable.keySet().iterator();while(its.hasNext()){String key = Util.getString(its.next());ErpMarket erpMarket = (ErpMarket)erpMarketTable.get(key);if(parentCode.equals(erpMarket.getParentCode())){erpMarketList.add(erpMarket);}}return erpMarketList;}省市区的实体类package com.erp.entity;/*** ErpMarket entity.** @author MyEclipse Persistence Tools*/public class ErpMarket implements java.io.Serializable {// Fieldsprivate String code;private String shortCode;private String name;private String level;private String parentCode;// Constructors/** default constructor */public ErpMarket() {}/** full constructor */public ErpMarket(String shortCode, String name, String level, String parentCode) {this.shortCode = shortCode; = name;this.level = level;this.parentCode = parentCode;}// Property accessorspublic String getCode() {return this.code;}public void setCode(String code) {this.code = code;}public String getShortCode() {return this.shortCode;}public void setShortCode(String shortCode) {this.shortCode = shortCode;}public String getName() {return ;}public void setName(String name) { = name;}public String getLevel() {return this.level;}public void setLevel(String level) {this.level = level;}public String getParentCode() {return this.parentCode;}public void setParentCode(String parentCode) {this.parentCode = parentCode;}}以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

js全国省区下拉列表级联

js全国省区下拉列表级联

js全国省区下拉列表级联//北京市辖区名称var city1 = ["东城区","西城区","崇文区","宣武区","朝阳区","海淀区","丰台区","石景山区","房山区","通州区","顺义区","门头沟区","昌平区","大兴区","怀柔区","平谷区","密云县","延庆县"];//上海市辖区名称var city2 = ["黄浦区","卢湾区","徐汇区","长宁区","静安区","普陀区","闸北区","虹口区","杨浦区","宝山区","闵行区","嘉定区","浦东新区","金山区","松江区","青浦区","南汇区","奉贤区","崇明县"];//天津市辖区名称var city3 = ["和平区","河东区","河西区","南开区","河北区","红桥区","塘沽区","汉沽区","大港区","东丽区","西青区","津南区","北辰区","武清区","宝坻区","宁河县","静海县","蓟县"];//重庆市辖区名称var city4 = ["渝中区","大渡口区","江北区","沙坪坝区","九龙坡区","南岸区","北碚区","万盛区","双桥区","渝北区","巴南区","万县区","涪陵区","永川市","合川市","江津市","南川市","长寿县","綦江县","潼南县","荣昌县","壁山县","大足县","铜梁县","梁平县","城口县","垫江县","武隆县","丰都县","忠县","开县","云阳县","青龙镇青龙嘴","奉节县","巫山县","巫溪县","南宾镇","中和镇","钟多镇","联合镇","汉葭镇"];//河北省主要城市名称var city5 = ["石家庄市","唐山市","秦皇岛市","邯郸市","邢台市","保定市","张家口市","承德市","沧州市","廊坊市","衡水市"];//山西省主要城市名称var city6 = ["太原市","大同市","阳泉市","长治市","晋城市","朔州市","晋中市","运城市","忻州市","临汾市","吕梁市"];//辽宁省主要城市名称var city7 = ["沈阳市","大连市","鞍山市","抚顺市","本溪市","丹东市","锦州市","营口市","阜新市","辽阳市","盘锦市","铁岭市","朝阳市","葫芦岛市"];//吉林省主要城市名称var city8 = ["长春市","吉林市","四平市","辽源市","通化市","白山市","松原市","白城市","延边朝鲜族自治州"];//河南省主要城市名称var city9 = ["郑州市","开封市","洛阳市","平顶山市","安阳市","鹤壁市","新乡市","焦作市","濮阳市","许昌市","漯河市","三门峡市","南阳市","商丘市","信阳市","周口市","驻马店市","济源市"];//江苏省主要城市名称var city10 = ["南京市","无锡市","徐州市","常州市","苏州市","南通市","连云港市","淮安市","盐城市","扬州市","镇江市","泰州市","宿迁市"];//浙江省主要城市名称var city11 = ["杭州市","宁波市","温州市","嘉兴市","湖州市","绍兴市","金华市","衢州市","舟山市","台州市","丽水市"];//安徽省主要城市名称var city12 = ["合肥市","芜湖市","蚌埠市","淮南市","马鞍山市","淮北市","铜陵市","安庆市","黄山市","滁州市","阜阳市","宿州市","巢湖市","六安市","亳州市","池州市","宣城市"];//福建省主要城市名称var city13 = ["福州市","厦门市","莆田市","三明市","泉州市","漳州市","南平市","龙岩市","宁德市"];//江西省主要城市名称var city14 = ["南昌市","景德镇市","萍乡市","九江市","新余市","鹰潭市","赣州市","吉安市","宜春市","抚州市","上饶市"];//山东省主要城市名称var city15 = ["济南市","青岛市","淄博市","枣庄市","东营市","烟台市","潍坊市","威海市","济宁市","泰安市","日照市","莱芜市","临沂市","德州市","聊城市","滨州市","菏泽市"];//湖北省主要城市名称var city16 = ["武汉市","黄石市","襄樊市","十堰市","荆州市","宜昌市","荆门市","鄂州市","孝感市","黄冈市","咸宁市","随州市","恩施州","仙桃市","潜江市","天门市","神农架林区"];//湖南省主要城市名称var city17 = ["长沙市","株洲市","湘潭市","衡阳市","邵阳市","岳阳市","常德市","张家界市","益阳市","郴州市","永州市","怀化市","娄底市","湘西州"];//广东省主要城市名称var city18 = ["广州市","深圳市","珠海市","汕头市","韶关市","佛山市","江门市","湛江市","茂名市","肇庆市","惠州市","梅州市","汕尾市","河源市","阳江市","清远市","东莞市","中山市","潮州市","揭阳市","云浮市"];//海南省主要城市名称var city19 = ["海口市","龙华区","秀英区","琼山区","美兰区","三亚市"];//四川省主要城市名称var city20 = ["成都市","自贡市","攀枝花市","泸州市","德阳市","绵阳市","广元市","遂宁市","内江市","乐山市","南充市","宜宾市","广安市","达州市","眉山市","雅安市","巴中市","资阳市","阿坝州","甘孜州","凉山州"];//贵州省主要城市名称var city21 = ["贵阳市","六盘水市","遵义市","安顺市","铜仁地区","毕节地区","黔西南州","黔东南州","黔南州"];//云南省主要城市名称var city22 = ["昆明市","大理市","曲靖市","玉溪市","昭通市","楚雄市","红河市","文山市","思茅市","西双版纳市","保山市","德宏市","丽江市","怒江市","迪庆市","临沧市"];//陕西省主要城市名称var city23 = ["西安市","铜川市","宝鸡市","咸阳市","渭南市","延安市","汉中市","榆林市","安康市","商洛市"];//甘肃省主要城市名称var city24 = ["兰州市","嘉峪关市","金昌市","白银市","天水市","武威市","张掖市","平凉市","酒泉市","庆阳市","定西市","陇南市","临夏州","甘南州"];//青海省主要城市名称var city25 = ["西宁市","海东地区","海北州","黄南州","海南州","果洛州","玉树州","海西州"];//黑龙江省主要城市名称var city26 = ["哈尔滨市","齐齐哈尔市","鸡西市","鹤岗市","双鸭山市","大庆市","伊春市","佳木斯市","七台河市","牡丹江市","黑河市","绥化市","大兴安岭地区"];//内蒙古自治区主要城市名称var city27 = ["呼和浩特市","包头市","乌海市","赤峰市","通辽市","鄂尔多斯市","呼伦贝尔市","巴彦淖尔市","乌兰察布市","兴安盟","锡林郭勒盟","阿拉善盟"];//广西壮族自治区主要城市名称var city28 = ["南宁市","柳州市","桂林市","梧州市","北海市","防城港市","钦州市","贵港市","玉林市","百色市","贺州市","河池市","来宾市","崇左市"];//西藏自治区主要城市名称var city29 = ["拉萨市","昌都地区","山南地区","日喀则地区","那曲地区","阿里地区","林芝地区"];//宁夏回族自治区主要城市名称var city30 = ["银川市","石嘴山市","吴忠市","固原市","中卫市"];//新疆维吾尔自治区主要城市名称var city31 = ["乌鲁木齐市","克拉玛依市","吐鲁番地区","哈密地区","和田地区","阿克苏地区","喀什地区","克孜勒苏柯尔克孜自治州","巴音郭楞蒙古自治州","昌吉回族自治州","博尔塔拉蒙古自治州","伊犁哈萨克自治州","塔城地区","阿勒泰地区","石河子市","阿拉尔市","图木舒克市","五家渠市"];//台湾省主要城市名称var city32 = ["台北市","高雄市","基隆市","台中市","台南市","新竹市","嘉义市","台北县","宜兰县","桃园县","新竹县","苗栗县","台中县","彰化县","南投县","云林县","嘉义县","台南县","高雄县","屏东县","澎湖县","台东县","花莲县"];//香港特别行政区主要辖区名称var city33 = ["中西区","东区","九龙城区","观塘区","南区","深水埗区","黄大仙区","湾仔区","油尖旺区","离岛区","葵青区","北区","西贡区","沙田区","屯门区","大埔区","荃湾区","元朗区"];//澳门地区var city34 = ["澳门地区"];//其它地区var city35 = ["其它地区"];//全国省会,直辖市,自治区名称var provinceName = ["北京市","上海市","天津市","重庆市","河北省","山西省","辽宁省","吉林省","河南省","江苏省","浙江省","安徽省","福建省","江西省","山东省","湖北省","湖南省","广东省","海南省","四川省","贵州省","云南省","陕西省","甘肃省","青海省","黑龙江省","内蒙古自治区","广西壮族自治区","西藏自治区","宁夏回族自治区","新疆维吾尔自治区","台湾省","香港特别行政区","澳门特别行政区","其它"];。

三级联动模板

三级联动模板

三级联动模板三级联动模板通常用于创建三个级别的联动效果,例如省市区三级联动。

以下是一个简单的三级联动模板示例:```html<!DOCTYPE html><html><head><title>省市区三级联动</title><script src="</head><body><select id="province"><option value="">请选择省份</option></select><select id="city"><option value="">请选择城市</option></select><select id="county"><option value="">请选择县区</option></select><script type="text/javascript">$(document).ready(function() {// 获取省份数据,填充省份下拉框var provinceData = [{ name: '省份1', cities: ['城市1', '城市2'] },{ name: '省份2', cities: ['城市3', '城市4'] },// 其他省份数据...];$.each(provinceData, function(index, item) {$('province').append('<option value="' + index + '">' + +'</option>');});// 省份选择变化事件,根据选择的省份获取对应城市数据,填充城市下拉框$('province').change(function() {var selectedProvinceIndex = $(this).val();var cities = provinceData[selectedProvinceIndex].cities;$('city').empty();$.each(cities, function(index, city) {$('city').append('<option value="' + index + '">' + city +'</option>');});});// 城市选择变化事件,根据选择的城市获取对应县区数据,填充县区下拉框$('city').change(function() {var selectedCityIndex = $(this).val();var counties =provinceData[$('province').val()].cities[selectedCityIndex];$('county').empty();$.each(counties, function(index, county) {$('county').append('<option value="' + index + '">' + county + '</option>');});});});</script></body></html>```这个模板中使用了jQuery库来实现省市区三级联动的功能。

省市级联js文件

省市级联js文件

省市级联js文件JS联动效果代码//province(省份类)function provinceList(){this.length=35;this[0] = new Option("安徽","0"); this[1] = new Option("北京","1"); this[2] = new Option("重庆","2"); this[3] = new Option("福建","3"); this[4] = new Option("甘肃","4"); this[5] = new Option("广东","5"); this[6] = new Option("广西","6"); this[7] = new Option("贵州","7"); this[8] = new Option("海南","8"); this[9] = new Option("河北","9"); this[10] = new Option("河南","10"); this[11] = new Option("黑龙江","11"); this[12] = new Option("湖北","12"); this[13] = new Option("湖南","13"); this[14] = new Option("江苏","14"); this[15] = new Option("江西","15"); this[16] = new Option("吉林","16"); this[17] = new Option("辽宁","17"); this[18] = new Option("内蒙古","18"); this[19] = new Option("宁夏","19"); this[20] = new Option("青海","20"); this[21] = new Option("上海","21");this[23] = new Option("山西","23"); this[24] = new Option("陕西","24"); this[25] = new Option("四川","25"); this[26] = new Option("天津","26"); this[27] = new Option("新疆","27"); this[28] = new Option("西藏","28"); this[29] = new Option("云南","29"); this[30] = new Option("浙江","30"); this[31] = new Option("香港","31"); this[32] = new Option("澳门","32"); this[33] = new Option("台湾","33"); this[34] = new Option("其它","34"); return this;}//city(城市类)function citylist(){this.length=35;this[0] = new Array(17);this[0][0] = new Option("合肥市","0"); this[0][1] = new Option("淮北市","1"); this[0][2] = new Option("淮南市","2"); this[0][3] = new Option("黄山市","3"); this[0][4] = new Option("安庆市","4"); this[0][5] = new Option("蚌埠市","5"); this[0][6] = new Option("巢湖市","6"); this[0][7] = new Option("池州市","7"); this[0][8] = new Option("滁州市","8");this[0][10] = new Option("马鞍山市","10");this[0][11] = new Option("宣城市","11");this[0][12] = new Option("宿州市","12");this[0][13] = new Option("铜陵市","13");this[0][14] = new Option("芜湖市","14");this[0][15] = new Option("阜阳市","15");this[0][16] = new Option("亳州市","16");this[1] = new Array(1);this[1][0] = new Option("北京市","100");this[2] = new Array(4);this[2][0] = new Option("重庆市","200");this[2][1] = new Option("涪陵市","201");this[2][2] = new Option("黔江市","202");this[2][3] = new Option("万县市","203");this[3] = new Array(9);this[3][0] = new Option("福州市","300");this[3][1] = new Option("龙岩市","301");this[3][2] = new Option("南平市","302");this[3][3] = new Option("宁德市","303");this[3][4] = new Option("莆田市","304");this[3][5] = new Option("泉州市","305");this[3][6] = new Option("三明市","306");this[3][7] = new Option("厦门市","307");this[3][8] = new Option("漳州市","308");this[4] = new Array(14);this[4][0] = new Option("兰州市","400");this[4][1] = new Option("甘南藏族自治州","401"); this[4][2] = new Option("定西地区","402");this[4][4] = new Option("嘉峪关市","404");this[4][5] = new Option("金昌市","405");this[4][6] = new Option("酒泉市","406");this[4][7] = new Option("临夏回族自治州","407"); this[4][8] = new Option("陇南地区","408");this[4][9] = new Option("平凉市","409");this[4][10] = new Option("庆阳市","410");this[4][11] = new Option("天水市","411");this[4][12] = new Option("武威市","412");this[4][13] = new Option("张掖市","413");this[5] = new Array(21);this[5][0] = new Option("广州市","500");this[5][1] = new Option("佛山市","501");this[5][2] = new Option("惠州市","502");this[5][3] = new Option("东莞市","503");this[5][4] = new Option("江门市","504");this[5][5] = new Option("揭阳市","505");this[5][6] = new Option("潮州市","506");this[5][7] = new Option("茂名市","507");this[5][8] = new Option("梅州市","508");this[5][9] = new Option("清远市","509");this[5][10] = new Option("汕头市","510");this[5][11] = new Option("汕尾市","511");this[5][12] = new Option("深圳市","512");this[5][13] = new Option("韶关市","513");this[5][14] = new Option("阳江市","514");this[5][15] = new Option("河源市","515");this[5][16] = new Option("云浮市","516");this[5][17] = new Option("中山市","517");this[5][19] = new Option("湛江市","519");this[5][20] = new Option("肇庆市","520");this[6] = new Array(14);this[6][0] = new Option("南宁市","600");this[6][1] = new Option("防城港市","601");this[6][2] = new Option("北海市","602");this[6][3] = new Option("百色市","603");this[6][4] = new Option("贺州市","604");this[6][5] = new Option("桂林市","605");this[6][6] = new Option("来宾市","606");this[6][7] = new Option("柳州市","607");this[6][8] = new Option("崇左市","608");this[6][9] = new Option("钦州市","609");this[6][10] = new Option("贵港市","610");this[6][11] = new Option("梧州市","611");this[6][12] = new Option("河池市","612");this[6][13] = new Option("玉林市","613");this[7] = new Array(9);this[7][0] = new Option("贵阳市","700");this[7][1] = new Option("毕节地区","701");this[7][2] = new Option("遵义市","702");this[7][3] = new Option("安顺市","703");this[7][4] = new Option("六盘水市","704");this[7][5] = new Option("黔东南苗族侗族自治州","705"); this[7][6] = new Option("黔南布依族苗族自治州","706"); this[7][7] = new Option("黔西南布依族苗族自治","707"); this[7][8] = new Option("铜仁地区","708");this[8] = new Array(3);this[8][0] = new Option("海口市","800");this[8][2] = new Option("省直辖行政单位","802"); this[9] = new Array(11);this[9][0] = new Option("石家庄市","900");this[9][1] = new Option("邯郸市","901");this[9][2] = new Option("邢台市","902");this[9][3] = new Option("保定市","903");this[9][4] = new Option("张家口市","904");this[9][5] = new Option("沧州市","905");this[9][6] = new Option("承德市","906");this[9][7] = new Option("廊坊市","907");this[9][8] = new Option("秦皇岛市","908");this[9][9] = new Option("唐山市","909");this[9][10] = new Option("衡水市","910");this[10] = new Array(18);this[10][0] = new Option("郑州市","1000");this[10][1] = new Option("开封市","1001");this[10][2] = new Option("驻马店市","1002"); this[10][3] = new Option("安阳市","1003");this[10][4] = new Option("焦作市","1004");this[10][5] = new Option("洛阳市","1005");this[10][6] = new Option("濮阳市","1006");this[10][7] = new Option("漯河市","1007");this[10][8] = new Option("南阳市","1008");this[10][9] = new Option("平顶山市","1009"); this[10][10] = new Option("新乡市","1010"); this[10][11] = new Option("信阳市","1011"); this[10][12] = new Option("许昌市","1012"); this[10][13] = new Option("商丘市","1013"); this[10][14] = new Option("三门峡市","1014");this[10][16] = new Option("周口市","1016");this[10][17] = new Option("济源市","1017");this[11] = new Array(13);this[11][0] = new Option("哈尔滨市","1100");this[11][1] = new Option("大庆市","1101");this[11][2] = new Option("大兴安岭地区","1102");this[11][3] = new Option("鸡西市","1103");this[11][4] = new Option("佳木斯市","1104");this[11][5] = new Option("牡丹江市","1105");this[11][6] = new Option("齐齐哈尔市","1106");this[11][7] = new Option("七台河市","1107");this[11][8] = new Option("双鸭山市","1108");this[11][9] = new Option("绥化市","1109");this[11][10] = new Option("伊春市","1110");this[11][11] = new Option("鹤岗市","1111");this[11][12] = new Option("黑河市","1112");this[12] = new Array(14);this[12][0] = new Option("武汉市","1200");this[12][1] = new Option("黄冈市","1201");this[12][2] = new Option("黄石市","1202");this[12][3] = new Option("恩施土家族苗族自治州","1203"); this[12][4] = new Option("鄂州市","1204");this[12][5] = new Option("荆门市","1205");this[12][6] = new Option("荆州市","1206");this[12][7] = new Option("孝感市","1207");this[12][8] = new Option("省直辖县级行政单位","1208"); this[12][9] = new Option("十堰市","1209");this[12][11] = new Option("咸宁市","1211");this[12][12] = new Option("宜昌市","1212");this[12][13] = new Option("随州市","1213");this[13] = new Array(14);this[13][0] = new Option("长沙市","1300");this[13][1] = new Option("怀化市","1301");this[13][2] = new Option("郴州市","1302");this[13][3] = new Option("常德市","1303");this[13][4] = new Option("娄底市","1304");this[13][5] = new Option("邵阳市","1305");this[13][6] = new Option("湘潭市","1306");this[13][7] = new Option("湘西土家族苗族自治州","1307"); this[13][8] = new Option("衡阳市","1308");this[13][9] = new Option("永州市","1309");this[13][10] = new Option("益阳市","1310");this[13][11] = new Option("岳阳市","1311");this[13][12] = new Option("株洲市","1312");this[13][13] = new Option("张家界市","1313");this[14] = new Array(13);this[14][0] = new Option("南京市","1400");this[14][1] = new Option("淮安市","1401");this[14][2] = new Option("常州市","1402");this[14][3] = new Option("连云港市","1403");this[14][4] = new Option("南通市","1404");this[14][5] = new Option("徐州市","1405");this[14][6] = new Option("苏州市","1406");this[14][7] = new Option("无锡市","1407");this[14][8] = new Option("盐城市","1408");this[14][9] = new Option("扬州市","1409");this[14][11] = new Option("泰州市","1411");this[14][12] = new Option("宿迁市","1412");this[15] = new Array(11);this[15][0] = new Option("南昌市","1500");this[15][1] = new Option("抚州市","1501");this[15][2] = new Option("赣州市","1502");this[15][3] = new Option("吉安市","1503");this[15][4] = new Option("景德镇市","1504");this[15][5] = new Option("九江市","1505");this[15][6] = new Option("萍乡市","1506");this[15][7] = new Option("新余市","1507");this[15][8] = new Option("上饶市","1508");this[15][9] = new Option("鹰潭市","1509");this[15][10] = new Option("宜春市","1510");this[16] = new Array(9);this[16][0] = new Option("长春市","1600");this[16][1] = new Option("白城市","1601");this[16][2] = new Option("白山市","1602");this[16][3] = new Option("吉林市","1603");this[16][4] = new Option("辽源市","1604");this[16][5] = new Option("四平市","1605");this[16][6] = new Option("松原市","1606");this[16][7] = new Option("通化市","1607");this[16][8] = new Option("延边朝鲜族自治州","1608"); this[17] = new Array(14);this[17][0] = new Option("沈阳市","1700");this[17][1] = new Option("大连市","1701");this[17][2] = new Option("阜新市","1702");this[17][3] = new Option("抚顺市","1703");this[17][5] = new Option("鞍山市","1705"); this[17][6] = new Option("丹东市","1706"); this[17][7] = new Option("锦州市","1707"); this[17][8] = new Option("朝阳市","1708"); this[17][9] = new Option("辽阳市","1709"); this[17][10] = new Option("盘锦市","1710"); this[17][11] = new Option("铁岭市","1711"); this[17][12] = new Option("营口市","1712"); this[17][13] = new Option("葫芦岛市","1713"); this[18] = new Array(12);this[18][0] = new Option("呼和浩特市","1800"); this[18][1] = new Option("阿拉善盟","1801"); this[18][2] = new Option("巴彦淖尔盟","1802"); this[18][3] = new Option("包头市","1803"); this[18][4] = new Option("赤峰市","1804"); this[18][5] = new Option("兴安盟","1805"); this[18][6] = new Option("乌兰察布盟","1806"); this[18][7] = new Option("乌海市","1807"); this[18][8] = new Option("锡林郭勒盟","1808"); this[18][9] = new Option("呼伦贝尔盟","1809"); this[18][10] = new Option("伊克昭盟","1810"); this[18][11] = new Option("通辽市","1811"); this[19] = new Array(5);this[19][0] = new Option("银川市","1900"); this[19][1] = new Option("固原市","1901"); this[19][2] = new Option("石嘴山市","1902"); this[19][3] = new Option("吴忠市","1903"); this[19][4] = new Option("中卫市","1904"); this[20] = new Array(8);this[20][1] = new Option("海东地区","2001");this[20][2] = new Option("海南藏族自治州","2002");this[20][3] = new Option("海北藏族自治州","2003");this[20][4] = new Option("黄南藏族自治州","2004");this[20][5] = new Option("果洛藏族自治州","2005");this[20][6] = new Option("玉树藏族自治州","2006");this[20][7] = new Option("海西蒙古族藏族自治州","2007"); this[21] = new Array(1);this[21][0] = new Option("上海市","2100");this[22] = new Array(17);this[22][0] = new Option("济南市","2200");this[22][1] = new Option("东营市","2201");this[22][2] = new Option("滨州市","2202");this[22][3] = new Option("淄博市","2203");this[22][4] = new Option("德州市","2204");this[22][5] = new Option("济宁市","2205");this[22][6] = new Option("聊城市","2206");this[22][7] = new Option("临沂市","2207");this[22][8] = new Option("莱芜市","2208");this[22][9] = new Option("青岛市","2209");this[22][10] = new Option("日照市","2210");this[22][11] = new Option("威海市","2211");this[22][12] = new Option("泰安市","2212");this[22][13] = new Option("潍坊市","2213");this[22][14] = new Option("烟台市","2214");this[22][15] = new Option("菏泽市","2215");this[22][16] = new Option("枣庄市","2216");this[23] = new Array(11);this[23][0] = new Option("太原市","2300");this[23][2] = new Option("晋城市","2302");this[23][3] = new Option("晋中市","2303");this[23][4] = new Option("长治市","2304");this[23][5] = new Option("临汾市","2305");this[23][6] = new Option("吕梁地区","2306");this[23][7] = new Option("忻州市","2307");this[23][8] = new Option("朔州市","2308");this[23][9] = new Option("阳泉市","2309");this[23][10] = new Option("运城市","2310");this[24] = new Array(10);this[24][0] = new Option("西安市","2400");this[24][1] = new Option("宝鸡市","2401");this[24][2] = new Option("安康市","2402");this[24][3] = new Option("商洛市","2403");this[24][4] = new Option("铜川市","2404");this[24][5] = new Option("渭南市","2405");this[24][6] = new Option("咸阳市","2406");this[24][7] = new Option("延安市","2407");this[24][8] = new Option("汉中市","2408");this[24][9] = new Option("榆林市","2409");this[25] = new Array(21);this[25][0] = new Option("成都市","2500");this[25][1] = new Option("达川市","2501");this[25][2] = new Option("甘孜藏族自治州","2502"); this[25][3] = new Option("自贡市","2503");this[25][4] = new Option("阿坝藏族羌族自治州","2504"); this[25][5] = new Option("巴中市","2505");this[25][6] = new Option("德阳市","2506");this[25][7] = new Option("广安市","2507");this[25][9] = new Option("凉山彝族自治州","2509");this[25][10] = new Option("乐山市","2510");this[25][11] = new Option("攀枝花市","2511");this[25][12] = new Option("南充市","2512");this[25][13] = new Option("内江市","2513");this[25][14] = new Option("泸州市","2514");this[25][15] = new Option("绵阳市","2515");this[25][16] = new Option("遂宁市","2516");this[25][17] = new Option("雅安市","2517");this[25][18] = new Option("宜宾市","2518");this[25][19] = new Option("眉山市","2519");this[25][20] = new Option("资阳市","2520");this[26] = new Array(1);this[26][0] = new Option("天津市","2600");this[27] = new Array(15);this[27][0] = new Option("乌鲁木齐市","2700");this[27][1] = new Option("喀什地区","2701");this[27][2] = new Option("克孜勒苏柯尔克孜自治","2702"); this[27][3] = new Option("克拉玛依市","2703");this[27][4] = new Option("阿克苏地区","2704");this[27][5] = new Option("阿勒泰地区","2705");this[27][6] = new Option("巴音郭楞蒙古自治州","2706"); this[27][7] = new Option("哈密地区","2707");this[27][8] = new Option("博尔塔拉蒙古自治州","2708"); this[27][9] = new Option("昌吉回族自治州","2709");this[27][10] = new Option("塔城地区","2710");this[27][11] = new Option("吐鲁番地区","2711");this[27][12] = new Option("和田地区","2712");this[27][13] = new Option("石河子市","2713");this[27][14] = new Option("伊犁哈萨克自治州","2714"); this[28] = new Array(7);this[28][0] = new Option("拉萨市","2800");this[28][1] = new Option("阿里地区","2801");this[28][2] = new Option("昌都市","2802");this[28][3] = new Option("林芝地区","2803");this[28][4] = new Option("那曲地区","2804");this[28][5] = new Option("山南地区","2805");this[28][6] = new Option("日喀则地区","2806");this[29] = new Array(16);this[29][0] = new Option("昆明市","2900");this[29][1] = new Option("大理白族自治州","2901");this[29][2] = new Option("昭通市","2902");this[29][3] = new Option("保山市","2903");this[29][4] = new Option("德宏傣族景颇族自治州","2904"); this[29][5] = new Option("迪庆藏族自治州","2905");this[29][6] = new Option("楚雄彝族自治州","2906");this[29][7] = new Option("临沧地区","2907");this[29][8] = new Option("丽江市","2908");this[29][9] = new Option("怒江傈僳族自治州","2909");this[29][10] = new Option("曲靖市","2910");this[29][11] = new Option("思茅地区","2911");this[29][12] = new Option("西双版纳傣族自治州","2912"); this[29][13] = new Option("文山壮族苗族自治州","2913"); this[29][14] = new Option("红河哈尼族彝族自治州","2914"); this[29][15] = new Option("玉溪市","2915");this[30] = new Array(11);this[30][0] = new Option("杭州市","3000");this[30][1] = new Option("嘉兴市","3001");this[30][2] = new Option("金华市","3002");this[30][3] = new Option("衢州市","3003"); this[30][4] = new Option("丽水市","3004"); this[30][5] = new Option("宁波市","3005"); this[30][6] = new Option("绍兴市","3006"); this[30][7] = new Option("台州市","3007"); this[30][8] = new Option("温州市","3008"); this[30][9] = new Option("湖州市","3009"); this[30][10] = new Option("舟山市","3010"); this[31] = new Array(1);this[31][0] = new Option("香港","3100"); this[32] = new Array(1);this[32][0] = new Option("澳门","3200"); this[33] = new Array(1);this[33][0] = new Option("台湾","3300"); this[34] = new Array(7);this[34][0] = new Option("北美洲","3400"); this[34][1] = new Option("南美洲","3401"); this[34][2] = new Option("大洋洲","3402"); this[34][3] = new Option("欧洲","3403"); this[34][4] = new Option("亚洲","3404"); this[34][5] = new Option("非洲","3405"); this[34][6] = new Option("虚拟社团","3406"); return this;}//创建provincelist、citylist类实例var provinceOb=new provinceList();var cityOb=new citylist();//定义province、city变量,用于select元素var province;var city;//子函数添加城市function addCitys(province,city){var index=province.selectedIndex;for(var i=0;i<cityOb[index].length;i++) {try{city.add(cityOb[index][i]);}catch(e){city.add(cityOb[index][i],null);}}}//子函数删除城市function delCitys(city){// for(var i=0;i<city.length;i++)// {// city.remove(i);// }city.length=0;}//初始化地区下拉菜单function initialize(privinceId,cityId){//获取select元素province=document.getElementById("province"); city=document.getElementById("city");//循环添加省份到provincefor(var i=0;i<provinceOb.length;i++){try{province.add(provinceOb[i]);}catch(e){province.add(provinceOb[i],null);}}//初始化privinceIdif(privinceId==undefined){privinceId=0;}//设置province默认选项province.options[privinceId].selected=true;//添加城市到cityaddCitys(province,city);//设置city的默认选项if(cityId!=undefined){city.options[cityId].selected=true; }else{city.options[0].selected=true;}}//下拉列表改变事件function selectchange(province,city) {delCitys(city);addCitys(province,city);}。

javascript解析xml实现省市县三级联动的方法

javascript解析xml实现省市县三级联动的方法

javascript解析xml实现省市县三级联动的⽅法本⽂实例讲述了javascript解析xml实现省市县三级联动的⽅法。

分享给⼤家供⼤家参考。

具体实现⽅法如下:(该⽅法适⽤于任何常⽤浏览器)<body><div><span><select id="sheng" style="width: 100px"></select></span><span><select id="shi" style="width: 100px"></select></span><span><select id="xian" style="width: 100px"></select></span></div></body></html><script type="text/javascript"><!--function getXmlDoc(){var xmlDoc;try{//给IE浏览器创建⼀个空的微软 XML⽂档对象xmlDoc=new ActiveXObject("Microsoft.XMLDOM");}catch(err){try{//在 Firefox及其他浏览器(opera)中的 XML解析器创建⼀个空的 XML⽂档对象。

xmlDoc=document.implementation.createDocument("","",null);}catch(er){alert("所使⽤的浏览器版本太低了,该换更新了");}}//关闭异步加载,这样确保在⽂档完全加载之前解析器不会继续脚本的执⾏xmlDoc.async=false;//解析器加载名为 "xxx.xml" 的 XML ⽂档xmlDoc.load("city.xml");return xmlDoc;}window.onload=function(){var xmlDoc=getXmlDoc();//获取xml⽂件的根节点var root=xmlDoc.documentElement;//获取xml⽂件的根节点下⾯的省节点var provinces=root.childNodes;//获取页⾯中要显⽰的省、市和县的控件dom对象var sheng=document.getElementById("sheng");var shi=document.getElementById("shi");var xian=document.getElementById("xian");//遍历所有的省for(var i=0;i<provinces.length;i++){//查看该节点是否是元素节点也是为了实现不同浏览器之间的兼容性问题(1是元素节点 Node.ELEMENT_NODE ---1 -- 元素节点)if(provinces[i].nodeType==1){//创建⼀个option节点对象var shengopt=document.createElement("option");//为option省节点添加⽂本 shengopt.appendChild(document.createTextNode(provinces[i].getAttr ibute("name")));//为option省节点设置属性 shengopt.setAttribute("value",provinces[i].getAttribute("postcode "));//添加省到页⾯dom对象中sheng.appendChild(shengopt);}}//当省节点发⽣改变时触发事件sheng.onchange=function(){//获取省节点所有的option对象的集合var shengs=sheng.options;//获取选中option对象的selectedIndex(下标值)var num=shengs.selectedIndex;//清空市区shi.length=0;xian.length=0;//根据选中的省获取其value值的内容即xml⽂件中的postcode对应的值var ppostcode=shengs[num].getAttribute("value");//遍历所有的省for(var i=0;i<provinces.length;i++){//查看该节点是否是元素节点也是为了实现不同浏览器之间的兼容性问题(1是元素节点 Node.ELEMENT_NODE ---1 -- 元素节点) if(provinces[i].nodeType==1){//根据省获取其postcode值的内容即html⽂件中的value对应的值var postcode=provinces[i].getAttribute("postcode");if(postcode==ppostcode){//获取省节点的⼦节点var cities=provinces[i].childNodes;//清空shi.length=0;//遍历所有的市for(var i=0;i<cities.length;i++){//查看该节点是否是元素节点也是为了实现不同浏览器之间的兼容性问题(1是元素节点 Node.ELEMENT_NODE ---1 -- 元素节点) if(cities[i].nodeType==1){//创建⼀个option节点对象var shiopt=document.createElement("option");//为option市节点添加⽂本 shiopt.appendChild(document.createTextNode(cities[i].getAttribute ("name")));//为option市节点设置属性shiopt.setAttribute("value", cities[i].getAttribute("postcode"));//添加市到页⾯dom对象中shi.appendChild(shiopt);}}break;}}}}//当市节点发⽣改变时触发事件shi.onchange=function(){//获取市节点所有的option对象的集合var shis=shi.options;//获取选中option对象的selectedIndex(下标值)var num=shis.selectedIndex;//根据选中的市获取其value值的内容即xml⽂件中的postcode对应的值var spostcode=shis[num].getAttribute("value");//遍历所有的省for(var i=0;i<provinces.length;i++){//查看该节点是否是元素节点也是为了实现不同浏览器之间的兼容性问题(1是元素节点 Node.ELEMENT_NODE ---1 -- 元素节点) if(provinces[i].nodeType==1){//获取省节点的⼦节点var cities=provinces[i].childNodes;//遍历所有的市for(var j=0;j<cities.length;j++){//查看该节点是否是元素节点也是为了实现不同浏览器之间的兼容性问题(1是元素节点 Node.ELEMENT_NODE ---1 -- 元素节点) if(cities[j].nodeType==1){//根据市获取其postcode值的内容即html⽂件中的 value对应的值var postcode=cities[j].getAttribute("postcode");if(postcode==spostcode){//清空xian.length=0;//获取市节点的⼦节点var areas=cities[j].childNodes;//遍历所有的区(县)for(var k=0;k<areas.length;k++){//查看该节点是否是元素节点也是为了实现不同浏览器之间的兼容性问题(1是元素节点 Node.ELEMENT_NODE ---1 -- 元素节点) if(areas[k].nodeType==1){//创建⼀个option节点对象var xianopt=document.createElement("option");//为option区节点添加⽂本xianopt.appendChild(document.createTextNode(areas[k].getAttribute ("name")));//为option区节点设置属性xianopt.setAttribute("value", areas[k].getAttribute("postcode"));//添加区到页⾯dom对象中xian.appendChild(xianopt);}}break;}}}}}}}//--></script>Xml⽂件(简写版)<root name="中国"><province name="请选择省" postcode="100000" ><city name="请选择市" postcode="100100" ><area name="请选择区" postcode="100101" /></city></province><province name="北京市" postcode="110000" ><city name="市辖区" postcode="110100" ><area name="东城区" postcode="110101" /><area name="西城区" postcode="110102" /><area name="崇⽂区" postcode="110103" /><area name="宣武区" postcode="110104" /><area name="朝阳区" postcode="110105" /><area name="丰台区" postcode="110106" /><area name="⽯景⼭区" postcode="110107" /><area name="海淀区" postcode="110108" /><area name="门头沟区" postcode="110109" /><area name="房⼭区" postcode="110111" /><area name="通州区" postcode="110112" /><area name="顺义区" postcode="110113" /><area name="昌平区" postcode="110114" /><area name="⼤兴区" postcode="110115" /><area name="怀柔区" postcode="110116" /><area name="平⾕区" postcode="110117" /></city><city name="县" postcode="110200" ><area name="密云县" postcode="110228" /><area name="延庆县" postcode="110229" /></city></province></root>希望本⽂所述对⼤家的javascript程序设计有所帮助。

全国地区选择(三级联动)

全国地区选择(三级联动)

全国地区选择(三级联动)1、新建HTML⽂件,引⼊必须的js⽂件。

<script src="../js/jquery.min.js"></script> //⾃⾏引⼊<script src="../js/Area.js"></script><script src="../js/AreaData_min.js"></script>Area.js:1// 地址选择三级联动2 $(function (){3 initComplexArea('seachprov', 'seachcity', 'seachdistrict', area_array, sub_array, '0', '0', '0');4 });5//得到地区码6function getAreaID(){7var area = 0;8if($("#seachdistrict").val() != "0"){9 area = $("#seachdistrict").val();10 }else if ($("#seachcity").val() != "0"){11 area = $("#seachcity").val();12 }else{13 area = $("#seachprov").val();14 }15return area;16 }17function showAreaID() {18//地区码19var areaID = getAreaID();20//地区名21var areaName = getAreaNamebyID(areaID) ;22 }23//根据地区码查询地区名24function getAreaNamebyID(areaID){25var areaName = "";26if(areaID.length == 2){27 areaName = area_array[areaID];28 }else if(areaID.length == 4){29var index1 = areaID.substring(0, 2);30 areaName = area_array[index1] + " " + sub_array[index1][areaID];31 }else if(areaID.length == 6){32var index1 = areaID.substring(0, 2);33var index2 = areaID.substring(0, 4);34 areaName = area_array[index1] + " " + sub_array[index1][index2] + " " + sub_arr[index2][areaID];35 }36return areaName;37 }38function initComplexArea(a, k, h, p, q, d, b, l) {39var f = initComplexArea.arguments;40var m = document.getElementById(a);41var o = document.getElementById(k);42var n = document.getElementById(h);43var e = 0;44var c = 0;45if (p != undefined) {46if (d != undefined) {47 d = parseInt(d);48 }49else {50 d = 0;51 }52if (b != undefined) {53 b = parseInt(b);54 }55else {56 b = 0;57 }58if (l != undefined) {59 l = parseInt(l);60 }61else {62 l = 063 }64 n[0] = new Option("请选择 ", 0);65for (e = 0; e < p.length; e++) {66if (p[e] == undefined) {67continue;68 }69if (f[6]) {70if (f[6] == true) {71if (e == 0) {72continue73 }74 }75 }76 m[c] = new Option(p[e], e);77if (d == e) {78 m[c].selected = true;79 }80 c++81 }82if (q[d] != undefined) {87if ((e % 100) == 0) { continue }88 }89 } o[c] = new Option(q[d][e], e);90if (b == e) { o[c].selected = true } c++91 }92 }93 }94 }95function changeComplexProvince(f, k, e, d) {96var c = changeComplexProvince.arguments; var h = document.getElementById(e);97var g = document.getElementById(d); var b = 0; var a = 0; removeOptions(h); f = parseInt(f);98if (k[f] != undefined) {99for (b = 0; b < k[f].length; b++) {100if (k[f][b] == undefined) { continue }101if (c[3]) { if ((c[3] == true) && (f != 71) && (f != 81) && (f != 82)) { if ((b % 100) == 0) { continue } } } 102 h[a] = new Option(k[f][b], b); a++103 }104 }105 removeOptions(g); g[0] = new Option("请选择 ", 0);106if (f == 11 || f == 12 || f == 31 || f == 71 || f == 50 || f == 81 || f == 82) {107if ($("#" + d + "_div"))108 { $("#" + d + "_div").hide(); }109 }110else {111if ($("#" + d + "_div")) { $("#" + d + "_div").show(); }112 }113 }114115116function changeCity(c, a, t) {117 $("#" + a).html('<option value="0" >请选择</option>');118 $("#" + a).unbind("change");119 c = parseInt(c);120var _d = sub_arr[c];121var str = "";122if (_d) {123 str += "<option value='0' >请选择</option>";124for (var i = c * 100; i < _d.length; i++) {125if (_d[i] == undefined) continue;126 str += "<option value='" + i + "' >" + _d[i] + "</option>";127 }128 $("#" + a).html(str);129 }130131 }132133function removeOptions(c) {134if ((c != undefined) && (c.options != undefined)) {135var a = c.options.length;136for (var b = 0; b < a; b++) {137 c.options[0] = null;138 }139 }140 }AreaData_min.js:var area_array=[];var sub_array=[];area_array[0] = "请选择";sub_array[0]=[];sub_array[0][0]="请选择";area_array[11]="北京市";sub_array[11]=[];sub_array[11][0]="请选择";sub_array[11][1101]="东城区";sub_array[11][1102]="西城区";sub_array[11][1103]="崇⽂区";sub_array[11][1104]="宣武区";sub_array[11][1105]="朝阳区";sub_array[11][1106]="丰台区";sub_array[11][1107]="⽯景⼭区";sub_array[11][1108]="海淀区";sub_array[11][1109]="门头沟区";sub_array[11][1111]="房⼭区";sub_array[11][1112]="通州区";sub_array[11][1113]="顺义区";sub_array[11][1114]="昌平区";sub_array[11][1115]="⼤兴区";sub_array[11][1116]="怀柔区";sub_array[11][1117]="平⾕区";sub_array[11][1128]="密云县";sub_array[11][1129]="延庆县";area_array[12]="天津市";sub_array[12]=[];sub_array[12][0]="请选择";sub_array[12][1201]="和平区";sub_array[12][1202]="河东区";sub_array[12][1203]="河西区";sub_array[12][1204]="南开区";sub_array[12][1205]="河北区";sub_array[12][1206]="红桥区";sub_array[12][1207]="塘沽区";sub_array[12][1208]="汉沽区";sub_array[12][1223]="静海县";sub_array[12][1225]="蓟县";area_array[13]="河北省";sub_array[13]=[];sub_array[13][0]="请选择";sub_array[13][1301]="⽯家庄市"; sub_array[13][1302]="唐⼭市";sub_array[13][1303]="秦皇岛市"; sub_array[13][1304]="邯郸市";sub_array[13][1305]="邢台市";sub_array[13][1306]="保定市";sub_array[13][1307]="张家⼝市"; sub_array[13][1308]="承德市";sub_array[13][1309]="沧州市";sub_array[13][1310]="廊坊市";sub_array[13][1311]="衡⽔市";area_array[14]="⼭西省";sub_array[14]=[];sub_array[14][0]="请选择";sub_array[14][1401]="太原市";sub_array[14][1402]="⼤同市";sub_array[14][1403]="阳泉市";sub_array[14][1404]="长治市";sub_array[14][1405]="晋城市";sub_array[14][1406]="朔州市";sub_array[14][1407]="晋中市";sub_array[14][1408]="运城市";sub_array[14][1409]="忻州市";sub_array[14][1410]="临汾市";sub_array[14][1411]="吕梁市";area_array[15]="内蒙古";sub_array[15]=[];sub_array[15][0]="请选择";sub_array[15][1501]="呼和浩特市"; sub_array[15][1502]="包头市";sub_array[15][1503]="乌海市";sub_array[15][1504]="⾚峰市";sub_array[15][1505]="通辽市";sub_array[15][1506]="鄂尔多斯市"; sub_array[15][1507]="呼伦贝尔市"; sub_array[15][1508]="巴彦淖尔市"; sub_array[15][1509]="乌兰察布市"; sub_array[15][1522]="兴安盟";sub_array[15][1525]="锡林郭勒盟"; sub_array[15][1529]="阿拉善盟"; area_array[21]="辽宁省";sub_array[21]=[];sub_array[21][0]="请选择";sub_array[21][2101]="沈阳市";sub_array[21][2102]="⼤连市";sub_array[21][2103]="鞍⼭市";sub_array[21][2104]="抚顺市";sub_array[21][2105]="本溪市";sub_array[21][2106]="丹东市";sub_array[21][2107]="锦州市";sub_array[21][2108]="营⼝市";sub_array[21][2109]="⾩新市";sub_array[21][2110]="辽阳市";sub_array[21][2111]="盘锦市";sub_array[21][2112]="铁岭市";sub_array[21][2113]="朝阳市";sub_array[21][2114]="葫芦岛市"; area_array[22]="吉林省";sub_array[22]=[];sub_array[22][0]="请选择";sub_array[22][2201]="长春市";sub_array[22][2202]="吉林市";sub_array[22][2203]="四平市";sub_array[22][2204]="辽源市";sub_array[22][2205]="通化市";sub_array[22][2206]="⽩⼭市";sub_array[22][2207]="松原市";sub_array[22][2208]="⽩城市";sub_array[22][2224]="延边州";area_array[23]="⿊龙江省";sub_array[23]=[];sub_array[23][0]="请选择";sub_array[23][2301]="哈尔滨市"; sub_array[23][2302]="齐齐哈尔市"; sub_array[23][2303]="鸡西市";sub_array[23][2304]="鹤岗市";sub_array[23][2305]="双鸭⼭市"; sub_array[23][2306]="⼤庆市";sub_array[23][2307]="伊春市";sub_array[23][2308]="佳⽊斯市"; sub_array[23][2309]="七台河市"; sub_array[23][2310]="牡丹江市"; sub_array[23][2311]="⿊河市";sub_array[23][2312]="绥化市";sub_array[23][2327]="⼤兴安岭地区";sub_array[31][3108]="闸北区"; sub_array[31][3109]="虹⼝区"; sub_array[31][3110]="杨浦区"; sub_array[31][3112]="闵⾏区"; sub_array[31][3113]="宝⼭区"; sub_array[31][3114]="嘉定区"; sub_array[31][3115]="浦东新区"; sub_array[31][3116]="⾦⼭区"; sub_array[31][3117]="松江区"; sub_array[31][3118]="青浦区"; sub_array[31][3120]="奉贤区"; sub_array[31][3130]="崇明县"; area_array[32]="江苏省";sub_array[32]=[];sub_array[32][0]="请选择";sub_array[32][3201]="南京市"; sub_array[32][3202]="⽆锡市"; sub_array[32][3203]="徐州市"; sub_array[32][3204]="常州市"; sub_array[32][3205]="苏州市"; sub_array[32][3206]="南通市"; sub_array[32][3207]="连云港市"; sub_array[32][3208]="淮安市"; sub_array[32][3209]="盐城市"; sub_array[32][3210]="扬州市"; sub_array[32][3211]="镇江市"; sub_array[32][3212]="泰州市"; sub_array[32][3213]="宿迁市"; area_array[33]="浙江省";sub_array[33]=[];sub_array[33][0]="请选择";sub_array[33][3301]="杭州市"; sub_array[33][3302]="宁波市"; sub_array[33][3303]="温州市"; sub_array[33][3304]="嘉兴市"; sub_array[33][3305]="湖州市"; sub_array[33][3306]="绍兴市"; sub_array[33][3307]="⾦华市"; sub_array[33][3308]="衢州市"; sub_array[33][3309]="⾈⼭市"; sub_array[33][3310]="台州市"; sub_array[33][3311]="丽⽔市"; area_array[34]="安徽省";sub_array[34]=[];sub_array[34][0]="请选择";sub_array[34][3401]="合肥市"; sub_array[34][3402]="芜湖市"; sub_array[34][3403]="蚌埠市"; sub_array[34][3404]="淮南市"; sub_array[34][3405]="马鞍⼭市"; sub_array[34][3406]="淮北市"; sub_array[34][3407]="铜陵市"; sub_array[34][3408]="安庆市"; sub_array[34][3410]="黄⼭市"; sub_array[34][3411]="滁州市"; sub_array[34][3412]="⾩阳市"; sub_array[34][3413]="宿州市"; sub_array[34][3414]="巢湖市"; sub_array[34][3415]="六安市"; sub_array[34][3416]="亳州市"; sub_array[34][3417]="池州市"; sub_array[34][3418]="宣城市"; area_array[35]="福建省";sub_array[35]=[];sub_array[35][0]="请选择";sub_array[35][3501]="福州市"; sub_array[35][3502]="厦门市"; sub_array[35][3503]="莆⽥市"; sub_array[35][3504]="三明市"; sub_array[35][3505]="泉州市"; sub_array[35][3506]="漳州市"; sub_array[35][3507]="南平市"; sub_array[35][3508]="龙岩市"; sub_array[35][3509]="宁德市"; area_array[36]="江西省";sub_array[36]=[];sub_array[36][0]="请选择";sub_array[36][3601]="南昌市"; sub_array[36][3602]="景德镇市"; sub_array[36][3603]="萍乡市"; sub_array[36][3604]="九江市"; sub_array[36][3605]="新余市"; sub_array[36][3606]="鹰潭市"; sub_array[36][3607]="赣州市"; sub_array[36][3608]="吉安市"; sub_array[36][3609]="宜春市"; sub_array[36][3610]="抚州市"; sub_array[36][3611]="上饶市"; area_array[37]="⼭东省";sub_array[37]=[];sub_array[37][3708]="济宁市"; sub_array[37][3709]="泰安市"; sub_array[37][3710]="威海市"; sub_array[37][3711]="⽇照市"; sub_array[37][3712]="莱芜市"; sub_array[37][3713]="临沂市"; sub_array[37][3714]="德州市"; sub_array[37][3715]="聊城市"; sub_array[37][3716]="滨州市"; sub_array[37][3717]="菏泽市"; area_array[41]="河南省";sub_array[41]=[];sub_array[41][0]="请选择";sub_array[41][4101]="郑州市"; sub_array[41][4102]="开封市"; sub_array[41][4103]="洛阳市"; sub_array[41][4104]="平顶⼭市"; sub_array[41][4105]="安阳市"; sub_array[41][4106]="鹤壁市"; sub_array[41][4107]="新乡市"; sub_array[41][4108]="焦作市"; sub_array[41][4109]="濮阳市"; sub_array[41][4110]="许昌市"; sub_array[41][4111]="漯河市"; sub_array[41][4112]="三门峡市"; sub_array[41][4113]="南阳市"; sub_array[41][4114]="商丘市"; sub_array[41][4115]="信阳市"; sub_array[41][4116]="周⼝市"; sub_array[41][4117]="驻马店市"; sub_array[41][4118]="济源市"; area_array[42]="湖北省";sub_array[42]=[];sub_array[42][0]="请选择";sub_array[42][4201]="武汉市"; sub_array[42][4202]="黄⽯市"; sub_array[42][4203]="⼗堰市"; sub_array[42][4205]="宜昌市"; sub_array[42][4206]="襄阳市"; sub_array[42][4207]="鄂州市"; sub_array[42][4208]="荆门市"; sub_array[42][4209]="孝感市"; sub_array[42][4210]="荆州市"; sub_array[42][4211]="黄冈市"; sub_array[42][4212]="咸宁市"; sub_array[42][4213]="随州市"; sub_array[42][4228]="恩施州"; sub_array[42][4229]="仙桃市"; sub_array[42][4230]="潜江市"; sub_array[42][4231]="天门市"; sub_array[42][4232]="神农架"; sub_array[42][4233]="江汉油⽥"; area_array[43]="湖南省";sub_array[43]=[];sub_array[43][0]="请选择";sub_array[43][4301]="长沙市"; sub_array[43][4302]="株洲市"; sub_array[43][4303]="湘潭市"; sub_array[43][4304]="衡阳市"; sub_array[43][4305]="邵阳市"; sub_array[43][4306]="岳阳市"; sub_array[43][4307]="常德市"; sub_array[43][4308]="张家界市"; sub_array[43][4309]="益阳市"; sub_array[43][4310]="郴州市"; sub_array[43][4311]="永州市"; sub_array[43][4312]="怀化市"; sub_array[43][4313]="娄底市"; sub_array[43][4331]="湘西"; area_array[44]="⼴东省";sub_array[44]=[];sub_array[44][0]="请选择";sub_array[44][4401]="⼴州市"; sub_array[44][4402]="韶关市"; sub_array[44][4403]="深圳市"; sub_array[44][4404]="珠海市"; sub_array[44][4405]="汕头市"; sub_array[44][4406]="佛⼭市"; sub_array[44][4407]="江门市"; sub_array[44][4408]="湛江市"; sub_array[44][4409]="茂名市"; sub_array[44][4412]="肇庆市"; sub_array[44][4413]="惠州市"; sub_array[44][4414]="梅州市"; sub_array[44][4415]="汕尾市"; sub_array[44][4416]="河源市"; sub_array[44][4417]="阳江市"; sub_array[44][4418]="清远市"; sub_array[44][4419]="东莞市"; sub_array[44][4420]="中⼭市";sub_array[45]=[];sub_array[45][0]="请选择";sub_array[45][4501]="南宁市";sub_array[45][4502]="柳州市";sub_array[45][4503]="桂林市";sub_array[45][4504]="梧州市";sub_array[45][4505]="北海市";sub_array[45][4506]="防城港市";sub_array[45][4507]="钦州市";sub_array[45][4508]="贵港市";sub_array[45][4509]="⽟林市";sub_array[45][4510]="百⾊市";sub_array[45][4511]="贺州市";sub_array[45][4512]="河池市";sub_array[45][4513]="来宾市";sub_array[45][4514]="崇左市";area_array[46]="海南省";sub_array[46]=[];sub_array[46][0]="请选择";sub_array[46][4601]="海⼝市";sub_array[46][4602]="三亚市";sub_array[46][4603]="五指⼭市";sub_array[46][4604]="琼海市";sub_array[46][4605]="儋州市";sub_array[46][4607]="⽂昌市";sub_array[46][4608]="万宁市";sub_array[46][4609]="东⽅市";sub_array[46][4623]="定安县";sub_array[46][4624]="屯昌县";sub_array[46][4625]="澄迈县";sub_array[46][4626]="临⾼县";sub_array[46][4627]="⽩沙";sub_array[46][4628]="昌江";sub_array[46][4629]="乐东";sub_array[46][4630]="陵⽔";sub_array[46][4631]="保亭";sub_array[46][4632]="琼中";sub_array[46][4690]="洋浦经济开发区";area_array[50]="重庆市";sub_array[50]=[];sub_array[50][0]="请选择";sub_array[50][5001]="万州区";sub_array[50][5002]="涪陵区";sub_array[50][5003]="渝中区";sub_array[50][5004]="⼤渡⼝区";sub_array[50][5005]="江北区";sub_array[50][5006]="沙坪坝区";sub_array[50][5007]="九龙坡区";sub_array[50][5008]="南岸区";sub_array[50][5009]="北碚区";sub_array[50][5010]="万盛区";sub_array[50][5011]="双桥区";sub_array[50][5012]="渝北区";sub_array[50][5013]="巴南区";sub_array[50][5014]="黔江区";sub_array[50][5015]="长寿区";sub_array[50][5016]="江津区";sub_array[50][5017]="合川区";sub_array[50][5019]="南川区";sub_array[50][5022]="綦江县";sub_array[50][5023]="潼南县";sub_array[50][5024]="铜梁县";sub_array[50][5025]="⼤⾜县";sub_array[50][5026]="荣昌县";sub_array[50][5027]="璧⼭县";sub_array[50][5028]="梁平县";sub_array[50][5029]="城⼝县";sub_array[50][5030]="丰都县";sub_array[50][5031]="垫江县";sub_array[50][5032]="武隆县";sub_array[50][5033]="忠县";sub_array[50][5034]="开县";sub_array[50][5035]="云阳县";sub_array[50][5036]="奉节县";sub_array[50][5037]="巫⼭县";sub_array[50][5038]="巫溪县";sub_array[50][5040]="⽯柱⼟家族⾃治县"; sub_array[50][5041]="秀⼭⼟家族苗族⾃治县"; sub_array[50][5042]="⾣阳⼟家族苗族⾃治县"; sub_array[50][5043]="彭⽔苗族⼟家族⾃治县"; sub_array[50][5083]="永川区";sub_array[50][5084]="北部新区";area_array[51]="四川省";sub_array[51]=[];sub_array[51][0]="请选择";sub_array[51][5101]="成都市";sub_array[51][5103]="⾃贡市";sub_array[51][5104]="攀枝花市";sub_array[51][5105]="泸州市";sub_array[51][5106]="德阳市";sub_array[51][5107]="绵阳市";sub_array[51][5108]="⼴元市";sub_array[51][5109]="遂宁市";sub_array[51][5110]="内江市";sub_array[51][5117]="达州市"; sub_array[51][5118]="雅安市"; sub_array[51][5119]="巴中市"; sub_array[51][5120]="资阳市"; sub_array[51][5132]="阿坝州"; sub_array[51][5133]="⽢孜";sub_array[51][5134]="凉⼭";area_array[52]="贵州省";sub_array[52]=[];sub_array[52][0]="请选择";sub_array[52][5201]="贵阳市"; sub_array[52][5202]="六盘⽔市"; sub_array[52][5203]="遵义市"; sub_array[52][5204]="安顺市"; sub_array[52][5205]="毕节市"; sub_array[52][5206]="铜仁市"; sub_array[52][5223]="黔西南"; sub_array[52][5226]="黔东南"; sub_array[52][5227]="黔南布"; area_array[53]="云南省";sub_array[53]=[];sub_array[53][0]="请选择";sub_array[53][5301]="昆明市"; sub_array[53][5303]="曲靖市"; sub_array[53][5304]="⽟溪市"; sub_array[53][5305]="保⼭市"; sub_array[53][5306]="昭通市"; sub_array[53][5307]="丽江市"; sub_array[53][5308]="普洱市(*)"; sub_array[53][5309]="临沧市"; sub_array[53][5323]="楚雄";sub_array[53][5325]="红河";sub_array[53][5326]="⽂⼭";sub_array[53][5328]="西双版纳"; sub_array[53][5329]="⼤理";sub_array[53][5331]="德宏";sub_array[53][5333]="怒江";sub_array[53][5334]="迪庆";area_array[54]="西藏";sub_array[54]=[];sub_array[54][0]="请选择";sub_array[54][5401]="拉萨市"; sub_array[54][5421]="昌都地区"; sub_array[54][5422]="⼭南地区"; sub_array[54][5423]="⽇喀则地区"; sub_array[54][5424]="那曲地区"; sub_array[54][5425]="阿⾥地区"; sub_array[54][5426]="林芝地区"; area_array[61]="陕西省";sub_array[61]=[];sub_array[61][0]="请选择";sub_array[61][6101]="西安市"; sub_array[61][6102]="铜川市"; sub_array[61][6103]="宝鸡市"; sub_array[61][6104]="咸阳市"; sub_array[61][6105]="渭南市"; sub_array[61][6106]="延安市"; sub_array[61][6107]="汉中市"; sub_array[61][6108]="榆林市"; sub_array[61][6109]="安康市"; sub_array[61][6110]="商洛市"; sub_array[61][6151]="杨凌⽰范区"; area_array[62]="⽢肃省";sub_array[62]=[];sub_array[62][0]="请选择";sub_array[62][6201]="兰州市"; sub_array[62][6202]="嘉峪关市"; sub_array[62][6203]="⾦昌市"; sub_array[62][6204]="⽩银市"; sub_array[62][6205]="天⽔市"; sub_array[62][6206]="武威市"; sub_array[62][6207]="张掖市"; sub_array[62][6208]="平凉市"; sub_array[62][6209]="酒泉市"; sub_array[62][6210]="庆阳市"; sub_array[62][6211]="定西市"; sub_array[62][6212]="陇南市"; sub_array[62][6229]="临夏";sub_array[62][6230]="⽢南";area_array[63]="青海省";sub_array[63]=[];sub_array[63][0]="请选择";sub_array[63][6301]="西宁市"; sub_array[63][6321]="海东地区"; sub_array[63][6322]="海北";sub_array[63][6323]="黄南";sub_array[63][6325]="海南";sub_array[63][6326]="果洛";sub_array[63][6327]="⽟树";sub_array[63][6328]="海西";area_array[64]="宁夏";sub_array[64]=[];sub_array[64][0]="请选择";area_array[65]="新疆";sub_array[65]=[];sub_array[65][0]="请选择";sub_array[65][6501]="乌鲁⽊齐市";sub_array[65][6502]="克拉玛依市";sub_array[65][6521]="吐鲁番地区";sub_array[65][6522]="哈密地区";sub_array[65][6523]="昌吉";sub_array[65][6527]="博尔塔拉";sub_array[65][6528]="巴⾳郭楞";sub_array[65][6529]="阿克苏地区";sub_array[65][6530]="克孜勒";sub_array[65][6531]="喀什地区";sub_array[65][6532]="和⽥地区";sub_array[65][6540]="伊犁";sub_array[65][6542]="塔城地区";sub_array[65][6543]="阿勒泰地区";sub_array[65][6590]="⾃治区直辖县级⾏政单位"; area_array[71]="台湾省";sub_array[71]=[];sub_array[71][0]="请选择";sub_array[71][7101]="台北市";sub_array[71][7102]="⾼雄市";sub_array[71][7103]="基隆市";sub_array[71][7104]="台中市";sub_array[71][7105]="台南市";sub_array[71][7106]="新⽵市";sub_array[71][7107]="嘉义市";sub_array[71][7108]="台北县";sub_array[71][7109]="宜兰县";sub_array[71][7110]="新⽵县";sub_array[71][7111]="桃园县";sub_array[71][7112]="苗栗县";sub_array[71][7113]="台中县";sub_array[71][7114]="彰化县";sub_array[71][7115]="南投县";sub_array[71][7116]="嘉义县";sub_array[71][7117]="云林县";sub_array[71][7118]="台南县";sub_array[71][7119]="⾼雄县";sub_array[71][7120]="屏东县";sub_array[71][7121]="台东县";sub_array[71][7122]="花莲县";sub_array[71][7123]="澎湖县";area_array[81]="⾹港";sub_array[81]=[];sub_array[81][0]="请选择";sub_array[81][8101]="中西区";sub_array[81][8102]="东区";sub_array[81][8103]="九龙城区";sub_array[81][8104]="观塘区";sub_array[81][8105]="南区";sub_array[81][8106]="深⽔区";sub_array[81][8107]="湾仔区";sub_array[81][8108]="黄⼤仙区";sub_array[81][8109]="油尖旺区";sub_array[81][8110]="离岛区";sub_array[81][8111]="葵青区";sub_array[81][8112]="北区";sub_array[81][8113]="西贡区";sub_array[81][8114]="沙⽥区";sub_array[81][8115]="屯门区";sub_array[81][8116]="⼤埔区";sub_array[81][8117]="荃湾区";sub_array[81][8118]="元朗区";area_array[82]="澳门";sub_array[82]=[];sub_array[82][0]="请选择";sub_array[82][8201]="花地玛堂区";sub_array[82][8202]="圣安多尼堂区";sub_array[82][8203]="⼤堂区";sub_array[82][8204]="望德堂区";sub_array[82][8205]="风顺堂区";sub_array[82][8206]="嘉模堂区";sub_array[82][8207]="圣⽅济各堂区";var l_arr=[];var sub_arr=[];l_arr[1301]="⽯家庄市";sub_arr[1301]=[];sub_arr[1301][0]="请选择";sub_arr[1301][130102]="长安区";sub_arr[1301][130103]="桥东区";sub_arr[1301][130104]="桥西区";sub_arr[1301][130105]="新华区";sub_arr[1301][130107]="井陉矿区";sub_arr[1301][130108]="裕华区";sub_arr[1301][130121]="井陉县";sub_arr[1301][130123]="正定县";sub_arr[1301][130124]="栾城县";sub_arr[1301][130125]="⾏唐县";sub_arr[1301][130126]="灵寿县";sub_arr[1301][130127]="⾼⾢县";sub_arr[1301][130128]="深泽县";sub_arr[1301][130184]="新乐市"; sub_arr[1301][130185]="⿅泉市"; l_arr[1302]="唐⼭市";sub_arr[1302]=[];sub_arr[1302][0]="请选择";sub_arr[1302][130202]="路南区"; sub_arr[1302][130203]="路北区"; sub_arr[1302][130204]="古冶区"; sub_arr[1302][130205]="开平区"; sub_arr[1302][130207]="丰南区"; sub_arr[1302][130208]="丰润区"; sub_arr[1302][130223]="滦县"; sub_arr[1302][130224]="滦南县"; sub_arr[1302][130225]="乐亭县"; sub_arr[1302][130227]="迁西县"; sub_arr[1302][130229]="⽟⽥县"; sub_arr[1302][130230]="唐海县"; sub_arr[1302][130281]="遵化市"; sub_arr[1302][130283]="迁安市"; l_arr[1303]="秦皇岛市";sub_arr[1303]=[];sub_arr[1303][0]="请选择";sub_arr[1303][130302]="海港区"; sub_arr[1303][130303]="⼭海关区"; sub_arr[1303][130304]="北戴河区"; sub_arr[1303][130321]="青龙县"; sub_arr[1303][130322]="昌黎县"; sub_arr[1303][130323]="抚宁县"; sub_arr[1303][130324]="卢龙县"; l_arr[1304]="邯郸市";sub_arr[1304]=[];sub_arr[1304][0]="请选择";sub_arr[1304][130402]="邯⼭区"; sub_arr[1304][130403]="丛台区"; sub_arr[1304][130404]="复兴区"; sub_arr[1304][130406]="峰峰矿区"; sub_arr[1304][130421]="邯郸县"; sub_arr[1304][130423]="临漳县"; sub_arr[1304][130424]="成安县"; sub_arr[1304][130425]="⼤名县"; sub_arr[1304][130426]="涉县"; sub_arr[1304][130427]="磁县"; sub_arr[1304][130428]="肥乡县"; sub_arr[1304][130429]="永年县"; sub_arr[1304][130430]="邱县"; sub_arr[1304][130431]="鸡泽县"; sub_arr[1304][130432]="⼴平县"; sub_arr[1304][130433]="馆陶县"; sub_arr[1304][130434]="魏县"; sub_arr[1304][130435]="曲周县"; sub_arr[1304][130481]="武安市"; l_arr[1305]="邢台市";sub_arr[1305]=[];sub_arr[1305][0]="请选择";sub_arr[1305][130502]="桥东区"; sub_arr[1305][130503]="桥西区"; sub_arr[1305][130521]="邢台县"; sub_arr[1305][130522]="临城县"; sub_arr[1305][130523]="内丘县"; sub_arr[1305][130524]="柏乡县"; sub_arr[1305][130525]="隆尧县"; sub_arr[1305][130526]="任县"; sub_arr[1305][130527]="南和县"; sub_arr[1305][130528]="宁晋县"; sub_arr[1305][130529]="巨⿅县"; sub_arr[1305][130530]="新河县"; sub_arr[1305][130531]="⼴宗县"; sub_arr[1305][130532]="平乡县"; sub_arr[1305][130533]="威县"; sub_arr[1305][130534]="清河县"; sub_arr[1305][130535]="临西县"; sub_arr[1305][130581]="南宫市"; sub_arr[1305][130582]="沙河市"; l_arr[1306]="保定市";sub_arr[1306]=[];sub_arr[1306][0]="请选择";sub_arr[1306][130602]="新市区"; sub_arr[1306][130603]="北市区"; sub_arr[1306][130604]="南市区"; sub_arr[1306][130621]="满城县"; sub_arr[1306][130622]="清苑县"; sub_arr[1306][130623]="涞⽔县"; sub_arr[1306][130624]="⾩平县"; sub_arr[1306][130625]="徐⽔县"; sub_arr[1306][130626]="定兴县"; sub_arr[1306][130627]="唐县"; sub_arr[1306][130628]="⾼阳县"; sub_arr[1306][130629]="容城县"; sub_arr[1306][130630]="涞源县"; sub_arr[1306][130631]="望都县";。

三级联动步骤

三级联动步骤

三级联动地址一.添加文件①将hat_province(省),hat_city(市), hat_area(区县)导入数据库。

②在js文件中引入cms.js。

③CMSService直接粘贴到.cxsw.service中即可,不用修改。

④GetAreaServlet.GetCityServlet,GetProvinceServlet粘贴到.cxsw.servlet中(cms.js会使用到servlet)。

二.添加地址一栏(add.jsp)①回显省市县<script src="<%=request.getContextPath()%>/js/cms.js"></script>②页面一加载就显示省市县<body onload="getProvince()">③添加下拉菜单--地址<label>地址</label><label>省</label><selectid="province"name="province" onchange="getCity(this.value)"><option value="-1">请选择省份</option></select><label>市</label><select id="city"name="city" onchange="getCountry(this.value)"><option value="-1">请选择市</option></select><label>县: </label><select id="country" name="country"><option value="-1">请选择县</option></select>三.取地址(addServlet)①addServlet:DoGet():String province_id = request.getParameter("province");String city_id = request.getParameter("city");String country_id = request.getParameter("country");CMSService cmsService = new CMSService();String provinceName=cmsService.getProvinceName(province_id);String cityName=cmsService.getCityName(city_id);String countryName=cmsService.getCountryName(country_id);String address = provinceName+"-"+cityName+"-"+countryName;System.out.println("测试address:" + address);//测试成功知后删除该语句地址没有什么特殊之处,同“姓名”一样将address存储到Model,处理业务,响应即可。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

全国省市县三级联动(数据完整版)网页前台代码:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Defaul t" EnableEventValidation="false"%><%@ Register assembly="AjaxControlToolkit"namespace="AjaxControlToolkit" tagprefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""/TR/xhtml 1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head runat="server"><title>发电机销售网点</title></head><body><form id="form1" runat="server"><div align="center"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><fieldset ><legend>全国省市县</legend><fieldset style="width: 265px"><legend>省</legend><asp:DropDownList ID="DropDownList1" runat="server"AutoPostBack="True"></asp:DropDownList><cc1:CascadingDropDown ID="DropDownList1_CascadingDropDown" runat="server"Category="provice" Enabled="True" LoadingText="读取数据中.." PromptText="请选择省"TargetControlID="DropDownList1" ServicePath="WebService.asmx" ServiceMethod ="GetproviceNames"></cc1:CascadingDropDown></fieldset><fieldset style="width: 266px"><legend>市</legend><asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"></asp:DropDownList><cc1:CascadingDropDown ID="DropDownList2_CascadingDropDown" runat="server"Category="city" Enabled="True" TargetControlID="DropDownList2" LoadingText="读取数据中.." PromptText="请选择市" ParentControlID="DropDownList1"ServicePath="WebService.asmx" ServiceMethod="GetCityNames"></cc1:CascadingDropDown></fieldset><fieldset style="width: 266px"><legend>县</legend><asp:DropDownList ID="DropDownList3" runat="server"></asp:DropDownList><cc1:CascadingDropDown ID="DropDownList3_CascadingDropDown" runat="server" Ca tegory="District" TargetControlID="DropDownList3"Enabled="True" LoadingText="读取数据中.." ParentControlID="DropDownList2"ServicePath="WebService.asmx" ServiceMethod="GetDistrictNames"></cc1:CascadingDropDown></fieldset></fieldset></div></form></body></html>WebService代码using System;using System.Collections;using System.Linq;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;using System.Xml.Linq;//访问数据库命名空间using System.Data;using System.Data.SqlClient;//访问web.config命名空间using System.Web.Configuration;//导入ScriptServiceAttribute类的命名空间using System.Web.Script.Services;//返回CascadingDropDownNameValue数组所需的命名空间using AjaxControlToolkit;using System.Collections.Generic;using System.Collections.Specialized;///<summary>///WebService 的摘要说明///</summary>[WebService(Namespace = "/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]//若要允许使用 AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。

[System.Web.Script.Services.ScriptService]public class WebService : System.Web.Services.WebService{public WebService(){//如果使用设计的组件,请取消注释以下行//InitializeComponent();}[WebMethod]public CascadingDropDownNameValue[] GetproviceNames(string knownCategoryValues, string ca tegory){List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["Perso nal"].ConnectionString);SqlCommand comm = conn.CreateCommand();mandText = "select [ProvinceID],[ProvinceName] from [S_Province] order by 1";conn.Open();try{SqlDataReader dr = comm.ExecuteReader();while (dr.Read()){values.Add(new CascadingDropDownNameValue(dr[1].ToString(), dr[0].ToString()));}return values.ToArray();}finally{conn.Close();}}[WebMethod]public CascadingDropDownNameValue[] GetCityNames(string knownCategoryValues, string categ ory){StringDictionary kcv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategory Values);if (!kcv.ContainsKey("provice")){return null;}List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["Perso nal"].ConnectionString);SqlCommand comm = conn.CreateCommand();mandText = "select [CityID],[CityName] from [S_City] where [ProvinceID]=@Provi nceID order by 1";comm.Parameters.Add("@ProvinceID", SqlDbType.Int).Value = kcv["provice"];conn.Open();try{SqlDataReader dr = comm.ExecuteReader();while (dr.Read()){values.Add(new CascadingDropDownNameValue(dr[1].ToString(), dr[0].ToString()));}return values.ToArray();}finally{conn.Close();}}[WebMethod]public CascadingDropDownNameValue[] GetDistrictNames(string knownCategoryValues, string ca tegory){StringDictionary kcv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategory Values);if (!kcv.ContainsKey("city")){return null;}List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["Perso nal"].ConnectionString);SqlCommand comm = conn.CreateCommand();mandText = "select [DistrictID],[DistrictName] from [S_District] where [CityID]=@ CityID order by 1";comm.Parameters.Add("@CityID", SqlDbType.Int).Value = kcv["city"];conn.Open();try{SqlDataReader dr = comm.ExecuteReader();while (dr.Read()){values.Add(new CascadingDropDownNameValue(dr[1].ToString(), dr[0].ToString()));}return values.ToArray();}finally{conn.Close();}}}。

相关文档
最新文档