`

中国省市二级联动菜单

阅读更多

<SCRIPT LANGUAGE="JavaScript"> 

<!-- ###中国省市二级联动菜单开始##

function Dsy() 

this.Items = {}; 

Dsy.prototype.add = function(id,iArray) 

this.Items[id] = iArray; 

Dsy.prototype.Exists = function(id) 

if(typeof(this.Items[id]) == "undefined") return false; 

return true; 

}

 

function change(v){ 

var str="0"; 

for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));}; 

var ss=document.getElementById(s[v]); 

with(ss){ 

length = 0; 

options[0]=new Option(opt0[v],opt0[v]); 

if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v) 

if(dsy.Exists(str)){ 

ar = dsy.Items[str]; 

for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]); 

if(v)options[1].selected = true; 

if(++v<s.length){change(v);} 

}

 

var dsy = new Dsy();

 

dsy.add("0",["北京市","天津市","河北省","山西省","内蒙古","辽宁省","吉林省","黑龙江省","上海市"," 江苏省","浙江省","安徽省","福建省","江西省","山东省","河南省","湖北省","湖南省","广东省","广西自治区","海南省","重庆市","四川省","贵州省","云南省","西藏自治区","陕西省","甘肃省","青海省","宁夏回族自治区","新疆维吾尔自治区","香港特别行政区","澳门特别行政区","台湾省","其它"]);

 

dsy.add("0_0",["北京","东城区","西城区","崇文区","宣武区","朝阳区","丰台区","石景山区"," 海淀区(中关村)","门头沟区","房山区","通州区","顺义区","昌平区","大兴区","怀柔区","平谷区","密云县","延庆县"," 其他"]); 

dsy.add("0_1",["和平区","河东区","河西区","南开区","红桥区","塘沽区","汉沽区","大港区","西青区","津南区","武清区","蓟县","宁河县","静海县","其他"]); 

dsy.add("0_2",["石家庄市","张家口市","承德市","秦皇岛市","唐山市","廊坊市","衡水市","沧州市","邢台市","邯郸市","保定市","其他"]); 

dsy.add("0_3",["太原市","朔州市","大同市","长治市","晋城市","忻州市","晋中市","临汾市","吕梁市","运城市","其他"]); 

dsy.add("0_4",["呼和浩特市","包头市","赤峰市","呼伦贝尔市","鄂尔多斯市","乌兰察布市","巴彦淖尔市","兴安盟","阿拉善盟","锡林郭勒盟","其他"]); 

dsy.add("0_5",["沈阳市","朝阳市","阜新市","铁岭市","抚顺市","丹东市","本溪市","辽阳市","鞍山市","大连市","营口市","盘锦市","锦州市","葫芦岛市","其他"]); 

dsy.add("0_6",["长春市","白城市","吉林市","四平市","辽源市","通化市","白山市","延边朝鲜族自治州","其他"]); 

dsy.add("0_7",["哈尔滨市","七台河市","黑河市","大庆市","齐齐哈尔市","伊春市","佳木斯市","双鸭山市","鸡西市","大兴安岭地区(加格达奇)","牡丹江","鹤岗市","绥化市 ","其他"]); 

dsy.add("0_8",["黄浦区","卢湾区","徐汇区","长宁区","静安区","普陀区","闸北区","虹口区","杨浦区","闵行区","宝山区","嘉定区","浦东新区","金山区","松江区","青浦区","南汇区","奉贤区","崇明县","其他"]); 

dsy.add("0_9",["南京市","徐州市","连云港市","宿迁市","淮安市","盐城市","扬州市","泰州市","南通市","镇江市","常州市","无锡市","苏州市","其他"]);

dsy.add("0_10",["杭州市","湖州市","嘉兴市","舟山市","宁波市","绍兴市","衢州市","金华市","台州市","温州市","丽水市","其他"]);

dsy.add("0_11",["合肥市","宿州市","淮北市","亳州市","阜阳市","蚌埠市","淮南市","滁州市","马鞍山市","芜湖市","铜陵市","安庆市","黄山市","六安市","巢湖市","池州市","宣城市","其他"]);

dsy.add("0_12",["福州市","南平市","莆田市","三明市","泉州市","厦门市","漳州市","龙岩市","宁德市","其他"]);

dsy.add("0_13",["南昌市","九江市","景德镇市","鹰潭市","新余市","萍乡市","赣州市","上饶市","抚州市","宜春市","吉安市","其他"]);

dsy.add("0_14",["济南市","聊城市","德州市","东营市","淄博市","潍坊市","烟台市","威海市","青岛市","日照市","临沂市","枣庄市","济宁市","泰安市","莱芜市","滨州市","菏泽市","其他"]);

dsy.add("0_15",["郑州市","三门峡市","洛阳市","焦作市","新乡市","鹤壁市","安阳市","濮阳市","开封市","商丘市","许昌市","漯河市","平顶山市","南阳市","信阳市","周口市","驻马店市","其他"]);

dsy.add("0_16",["武汉市","十堰市","襄樊市","荆门市","孝感市","黄冈市","鄂州市","黄石市","咸宁市","荆州市","宜昌市","随州市","恩施土家族苗族自治州","仙桃市","天门市","潜江市","神农架林区","其他"]);

dsy.add("0_17",["长沙市","张家界市","常德市","益阳市","岳阳市","株洲市","湘潭市","衡阳市","郴州市","永州市","邵阳市","怀化市","娄底市","湘西土家族苗族自治州","其他"]);

dsy.add("0_18",["广州市","清远市市","韶关市","河源市","梅州市","潮州市","汕头市","揭阳市","汕尾市"," 惠州市","东莞市","深圳市","珠海市","中山市","江门市","佛山市","肇庆市","云浮市","阳江市","茂名市","湛江市"," 其他"]);

dsy.add("0_19",["南宁市","桂林市","柳州市","梧州市","贵港市","玉林市","钦州市","北海市","防城港市","崇左市","百色市","河池市","来宾市","贺州市","其他"]);

dsy.add("0_20",["海口市","三亚市","其他"]);

dsy.add("0_21",["渝中区","大渡口区","江北区","沙坪坝区","九龙坡区","南岸区","北碚区","万盛区","双桥区","渝北区","巴南区","万州区","涪陵区","黔江区","长寿区","合川市","永川市","江津市","南川市","綦江县","潼南县","铜梁县","大足县","璧山县","垫江县","武隆县","丰都县","城口县","开县","巫溪县","巫山县","奉节县","云阳县","忠县","石柱土家族自治县","彭水苗族土家族自治县","酉阳土家族苗族自治县","秀山土家族苗族自治县","其他"]);

dsy.add("0_22",["成都市","广元市","绵阳市","德阳市","南充市","广安市","遂宁市","内江市","乐山市","自贡市","泸州市","宜宾市","攀枝花市","巴中市","资阳市","眉山市","雅安","阿坝藏族羌族自治州","甘孜藏族自治州","凉山彝族自治州县","其他"]);

dsy.add("0_23",["贵阳市","六盘水市","遵义市","安顺市","毕节地区","铜仁地区","黔东南苗族侗族自治州","黔南布依族苗族自治州","黔西南布依族苗族自治州","其他"]);

dsy.add("0_24",["昆明市","曲靖市","玉溪市","保山市","昭通市","丽江市","普洱市","临沧市","宁德市","德宏傣族景颇族自治州","怒江傈僳族自治州","楚雄彝族自治州","红河哈尼族彝族自治州","文山壮族苗族自治州","大理白族自治州","迪庆藏族自治州","西双版纳傣族自治州","其他"]);

dsy.add("0_25",["拉萨市","那曲地区","昌都地区","林芝地区","山南地区","日喀则地区","阿里地区","其他"]);

dsy.add("0_26",["西安市","延安市","铜川市","渭南市","咸阳市","宝鸡市","汉中市","安康市","商洛市","其他"]);

dsy.add("0_27",["兰州市 ","嘉峪关市","金昌市","白银市","天水市","武威市","酒泉市","张掖市","庆阳市","平凉市","定西市","陇南市","临夏回族自治州","甘南藏族自治州","其他"]);

dsy.add("0_28",["西宁市","海东地区","海北藏族自治州","黄南藏族自治州","玉树藏族自治州","海南藏族自治州","果洛藏族自治州","海西蒙古族藏族自治州","其他"]);

dsy.add("0_29",["银川市","石嘴山市","吴忠市","固原市","中卫市","其他"]);

dsy.add("0_30",["乌鲁木齐市","克拉玛依市","喀什地区","阿克苏地区","和田地区","吐鲁番地区","哈密地区","塔城地区","阿勒泰地区","克孜勒苏柯尔克孜自治州","博尔塔拉蒙古自治州","昌吉回族自治州伊犁哈萨克自治州","巴音郭楞蒙古自治州","河子市","阿拉尔市","五家渠市","图木舒克市","其他"]);

dsy.add("0_31",["香港","其他"]);

dsy.add("0_31",["澳门","其他"])

dsy.add("0_32",["台湾","其他"])

//--> 

</SCRIPT> 

<SCRIPT LANGUAGE = JavaScript>

 

 

var s=["s1","s2"]; 

var opt0 = ["请选择","请选择"]; 

function setup() 

for(i=0;i<s.length-1;i++) 

document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")"); 

change(0); 

//##联动菜单结束--> 

</SCRIPT>

 

调用:<select name="lz_sf" id="s1">

<option></option></select> 

<select name="lz_sx" id="s2">

<option></option></select>

<script language="javascript"> 

   setup() 

</script>


分享到:
评论

相关推荐

    省市二级联动代码JS

    标题中的“省市二级联动代码JS”指的是在网页开发中实现的一种交互功能,它允许用户在选择省份后,自动更新下拉菜单以显示对应省份的城市,从而实现两级联动的效果。这种功能通常用于地址输入或者区域筛选等场景,...

    省市联动二级菜单

    "省市联动二级菜单"是一个常见的前端开发功能,主要用于在网页上实现省份与城市之间的联动选择。这个功能在很多网站的地址填写、用户信息完善等场景中广泛应用。在给定的压缩包文件中,可能包含了实现这一功能的源...

    全国最新2010年重新规划省市县二级联动菜单JS,但有区域代码哦

    全国最新2010年重新规划省市县二级联动菜单JS,但有区域代码哦,是自己写的!!不是COPY的!!

    基于mui写的H5移动端全国地区三级联动菜单

    通常,开发者会将这些文件打包在一起,以便其他开发者或使用者能够直接查看和运行代码,了解并学习如何实现这个三级联动菜单。 综上所述,这个项目的核心知识点包括: 1. HTML5技术,用于创建响应式的移动端页面。...

    jQuery+ASP+SQL实现二级联动下拉菜单

    jQuery+ASP+SQL实现二级联动下拉菜单 全国省市数据库可以从网上Down个合适的导入一下就可以了. /**************************** * Author:蓝客密探 * Blog:www.lanke.me * Forum:www.phpdn.cn 详细介绍页面:...

    jQuery省市二级联动关联店面查询表单代码

    在这个“jQuery省市二级联动关联店面查询表单代码”项目中,开发者利用jQuery实现了用户友好的店面查询功能,特别适用于网络营销场景,帮助用户快速找到连锁店铺的全国网点。 首先,我们要理解“省市二级联动”的...

    JS写的二级联动菜单

    二级联动菜单,JS写的。地区的选择,中国国外的省、市、区都做了联动

    (多个)省市区街道四级联动菜单

    在IT领域,尤其是在网页开发中,"四级联动菜单"是一种常见的交互设计,它通常用于让用户在选择地理位置时,依次从省、市、区/县到街道进行精细化选择。这种设计可以方便用户快速定位到具体的位置,同时也能为后台...

    Java实现Map集合二级联动示例

    在这个"Java实现Map集合二级联动示例中国省市例子"中,我们将探讨如何使用Map来构建一个二级联动的功能,常见于如中国省市选择的场景。这个场景通常出现在需要用户首先选择省份,然后根据所选省份展示对应的市的选择...

    中国省市二级联动sql语句

    在中国的信息化建设中,省市二级联动是一个常见的需求,特别是在网页设计和数据库开发中。它用于在用户选择省份后,自动加载对应的市一级选项,形成一个交互式的下拉菜单。这通常涉及到前端JavaScript与后端数据库的...

    Android 省市二级联动

    在本案例中,我们讨论的是一个实现“省市二级联动”的功能,即用户首先选择省份,然后根据所选省份显示出相应的城市供用户进一步选择。例如,用户可能会看到“四川省-成都市”或“重庆市-渝中区”这样的选项。 要...

    中国地区三级联动菜单

    在中国的Web开发中,"三级联动菜单"是一种常见的交互设计,尤其在选择地理位置或组织结构时,它能高效地展示多层次的信息。这个标题所指的"中国地区三级联动菜单"是一个专为选择中国地区设计的下拉菜单组件,通常...

    二级省市联动框架

    在中国的Web应用开发中,"二级省市联动"是一种常见的功能设计,主要用于地址选择或区域划分。这个功能使得用户在选择省份后,下拉菜单会自动更新出与所选省份对应的市,然后再选择市时,下拉菜单又会更新出对应区县...

    echars地图 省市二级联动 插件 源码

    "省市二级联动"的概念指的是,在一个下拉菜单选择省份后,另一个下拉菜单会自动更新为所选省份下的城市,提供连续的选择体验。在ECharts中实现这一功能,需要利用其强大的自定义事件和数据驱动特性。以下是实现这个...

    省市三级联动菜单(asp.net)

    在IT行业中,省市三级联动菜单是一项常见的前端交互功能,它常用于用户填写地址时的选择,如电子商务网站的订单系统。这种菜单设计允许用户按照省级、市级、区县级的顺序逐级选择,确保了地址信息的准确性和完整性。...

    中国行政区数据及三级联动菜单

    【中国行政区数据及三级联动菜单】是一个典型的前端开发项目,主要涉及地理信息系统(GIS)与用户界面交互的设计。在这个项目中,开发者提供了中国全部行政区域的数据,并实现了三级联动菜单的功能,便于用户在网页...

    省市二级联动的EasyUI及jar包

    标题 "省市二级联动的EasyUI及jar包" 暗示了这个压缩包可能包含用于实现中国省市二级联动效果的EasyUI组件和相关的Java库文件(jar包)。EasyUI是一个基于jQuery的轻量级前端框架,它提供了丰富的UI组件,如表格、...

    element-ui省市县三级联动菜单代码.zip

    在"element-ui省市县三级联动菜单代码.zip"这个压缩包中,我们可以推测其内含的示例是使用 Element UI 实现的中国省市县三级联动选择菜单。这种菜单在很多需要用户输入地址信息的场景下非常常见,例如在线购物、地图...

    实现全国省市区三级联动下拉菜单

    在这个“实现全国省市区三级联动下拉菜单”的项目中,我们将使用jQuery这一强大的JavaScript库来完成这个功能。 首先,我们需要理解什么是三级联动。在三级联动下拉菜单中,用户从一个下拉菜单中做出选择后,第二个...

Global site tag (gtag.js) - Google Analytics