关闭

中国地域信息联动下拉框的JS包

6139人阅读 评论(0) 收藏 举报

*这里是调用示例,时间原因没有很好处理,下载后自行修改

<script src=file:///F:/webform/biz/js/china.js></script>

<script>
var china
china = new ChinaClass

function fullchina()
{
 china.FullProvince(document.all.xxx)
}

function citys()
{
 china.FullCitys(document.all.aa,document.all.xxx.value)
}
</script>

<body onload="fullchina()">
<select id="xxx" size="1" onchange="citys()"></select>
<select id="aa" size="1"></select>
</body>

 

*这里是js代码,保存到一个js文件。

function ChinaClass()
{
 this.FullProvince = FullProvince;
 this.FullCitys = FullCitys;

 var province = new Array(); //declare a province object
 var  city = new Array(); //declare a  city object


 //----------------------
 //inti province of china
 //---------------------- 

 province[0] = new Array('1','台湾')
 province[1] = new Array('56','辽宁')
 province[2] = new Array('64','青海')
 province[3] = new Array('66','新疆')
 province[4] = new Array('68','陕西')
 province[5] = new Array('69','上海')
 province[6] = new Array('71','四川')
 province[7] = new Array('72','山西')
 province[8] = new Array('73','山东')
 province[9] = new Array('78','天津')
 province[10] = new Array('79','西藏')
 province[11] = new Array('106','浙江')
 province[12] = new Array('109','云南')
 province[13] = new Array('139','内蒙古')
 province[14] = new Array('140','宁夏')
 province[15] = new Array('141','重庆')
 province[16] = new Array('142','安徽')
 province[17] = new Array('143','北京')
 province[18] = new Array('144','甘肃')
 province[19] = new Array('145','福建')
 province[20] = new Array('146','广西')
 province[21] = new Array('147','广东')
 province[22] = new Array('148','贵州')
 province[23] = new Array('149','河南')
 province[24] = new Array('150','河北')
 province[25] = new Array('151','黑龙江')
 province[26] = new Array('152','海南')
 province[27] = new Array('153','湖南')
 province[28] = new Array('154','湖北')
 province[29] = new Array('155','吉林')
 province[30] = new Array('156','江苏')
 province[31] = new Array('157','江西')

 //----------------------
 //inti   city of china
 //----------------------

 city[0] = new Array('143','1','北京')
 city[1] = new Array('78','2','天津')
 city[2] = new Array('69','3','上海')
 city[3] = new Array('141','4','重庆')
 city[4] = new Array('150','5','邯郸')
 city[5] = new Array('150','6','石家庄')
 city[6] = new Array('150','7','保定')
 city[7] = new Array('150','8','张家口')
 city[8] = new Array('150','9','承德')
 city[9] = new Array('150','10','唐山')
 city[10] = new Array('150','11','廊坊')
 city[11] = new Array('150','12','沧州')
 city[12] = new Array('150','13','衡水')
 city[13] = new Array('150','14','邢台')
 city[14] = new Array('150','15','秦皇岛')
 city[15] = new Array('72','16','朔州')
 city[16] = new Array('72','17','忻州')
 city[17] = new Array('72','18','太原')
 city[18] = new Array('72','19','大同')
 city[19] = new Array('72','20','阳泉')
 city[20] = new Array('72','21','榆次(晋中)')
 city[21] = new Array('72','22','长冶')
 city[22] = new Array('72','23','晋城')
 city[23] = new Array('72','24','临汾')
 city[24] = new Array('72','25','孝义')
 city[25] = new Array('72','26','运城')
 city[26] = new Array('149','27','商丘')
 city[27] = new Array('149','28','郑州')
 city[28] = new Array('149','29','新乡')
 city[29] = new Array('149','30','许昌')
 city[30] = new Array('149','31','平顶山')
 city[31] = new Array('149','32','南阳')
 city[32] = new Array('149','33','开封')
 city[33] = new Array('149','34','洛阳')
 city[34] = new Array('149','35','焦作')
 city[35] = new Array('149','36','鹤壁')
 city[36] = new Array('149','37','濮阳')
 city[37] = new Array('149','38','漯河')
 city[38] = new Array('149','39','驻马店')
 city[39] = new Array('149','40','息县')
 city[40] = new Array('149','41','三门峡')
 city[41] = new Array('56','42','沈阳')
 city[42] = new Array('56','43','铁岭')
 city[43] = new Array('56','44','大连')
 city[44] = new Array('56','45','抚顺')
 city[45] = new Array('56','46','本溪')
 city[46] = new Array('56','47','丹东')
 city[47] = new Array('56','48','锦州')
 city[48] = new Array('56','49','营口')
 city[49] = new Array('56','50','阜新')
 city[50] = new Array('56','51','辽阳')
 city[51] = new Array('56','52','朝阳')
 city[52] = new Array('56','53','盘锦')
 city[53] = new Array('155','54','长春')
 city[54] = new Array('155','55','吉林')
 city[55] = new Array('155','56','延吉')
 city[56] = new Array('155','57','四平')
 city[57] = new Array('155','58','通化')
 city[58] = new Array('155','59','白城')
 city[59] = new Array('155','60','辽源')
 city[60] = new Array('155','61','松原')
 city[61] = new Array('155','62','白水')
 city[62] = new Array('155','63','珲春')
 city[63] = new Array('155','64','梅河口')
 city[64] = new Array('151','65','牡丹江')
 city[65] = new Array('151','66','佳木斯')
 city[66] = new Array('151','67','绥化')
 city[67] = new Array('151','68','黑河')
 city[68] = new Array('151','69','伊春')
 city[69] = new Array('151','70','大庆')
 city[70] = new Array('139','71','海拉尔(呼盟)')
 city[71] = new Array('139','72','呼和浩特')
 city[72] = new Array('139','73','包头')
 city[73] = new Array('139','74','乌海')
 city[74] = new Array('139','75','集宁')
 city[75] = new Array('139','76','通辽')
 city[76] = new Array('139','77','赤峰')
 city[77] = new Array('139','78','东胜')
 city[78] = new Array('139','79','临河(巴盟)')
 city[79] = new Array('139','80','锡林浩特')
 city[80] = new Array('139','81','阿拉善右旗')
 city[81] = new Array('156','82','南京')
 city[82] = new Array('156','83','无锡')
 city[83] = new Array('156','84','镇江')
 city[84] = new Array('156','85','苏州')
 city[85] = new Array('156','86','南通')
 city[86] = new Array('156','87','扬州')
 city[87] = new Array('156','88','盐城')
 city[88] = new Array('156','89','徐州')
 city[89] = new Array('156','90','连云港')
 city[90] = new Array('156','91','常州')
 city[91] = new Array('156','92','常熟')
 city[92] = new Array('156','93','泰州(姜堰)')
 city[93] = new Array('156','94','宿迁')
 city[94] = new Array('140','95','银川')
 city[95] = new Array('140','96','石嘴山')
 city[96] = new Array('140','97','青铜峡')
 city[97] = new Array('140','98','固原')
 city[98] = new Array('152','99','儋州')
 city[99] = new Array('152','100','海口')
 city[100] = new Array('152','101','三亚')
 city[101] = new Array('79','102','堆龙德庆')
 city[102] = new Array('79','103','曲水')
 city[103] = new Array('79','104','尼木')
 city[104] = new Array('79','105','仁布')
 city[105] = new Array('79','106','萨嘎')
 city[106] = new Array('79','107','岗巴')
 city[107] = new Array('79','108','萨迦')
 city[108] = new Array('79','109','定结')
 city[109] = new Array('79','110','定日')
 city[110] = new Array('79','111','聂拉木')
 city[111] = new Array('79','112','吉隆')
 city[112] = new Array('79','113','仲巴')
 city[113] = new Array('79','114','错那')
 city[114] = new Array('79','115','昂仁')
 city[115] = new Array('79','116','拉孜')
 city[116] = new Array('79','117','谢通门')
 city[117] = new Array('79','118','南木林')
 city[118] = new Array('79','119','隆子')
 city[119] = new Array('79','120','扎囊')
 city[120] = new Array('79','121','墨脱')
 city[121] = new Array('79','122','洛扎')
 city[122] = new Array('79','123','浪卡子')
 city[123] = new Array('79','124','贡嘎')
 city[124] = new Array('79','125','类乌齐')
 city[125] = new Array('79','126','江达')
 city[126] = new Array('79','127','贡觉')
 city[127] = new Array('79','128','芒康')
 city[128] = new Array('79','129','左贡')
 city[129] = new Array('79','130','八宿')
 city[130] = new Array('79','131','洛隆')
 city[131] = new Array('79','132','边坝')
 city[132] = new Array('79','133','丁青')
 city[133] = new Array('79','134','普兰')
 city[134] = new Array('79','135','巴青')
 city[135] = new Array('79','136','比如')
 city[136] = new Array('79','137','嘉黎')
 city[137] = new Array('79','138','聂荣')
 city[138] = new Array('79','139','班戈')
 city[139] = new Array('79','140','申扎')
 city[140] = new Array('79','141','措勤')
 city[141] = new Array('79','142','双湖')
 city[142] = new Array('79','143','扎达')
 city[143] = new Array('79','144','革吉')
 city[144] = new Array('79','145','樟木')
 city[145] = new Array('79','146','日土')
 city[146] = new Array('79','147','改则')
 city[147] = new Array('79','148','措美')
 city[148] = new Array('79','149','索县')
 city[149] = new Array('79','150','尼玛')
 city[150] = new Array('79','151','盐井')
 city[151] = new Array('79','152','拉萨')
 city[152] = new Array('79','153','日咯则市')
 city[153] = new Array('79','154','山南')
 city[154] = new Array('79','155','林芝')
 city[155] = new Array('79','156','昌都')
 city[156] = new Array('79','157','那曲')
 city[157] = new Array('66','158','和田/石河子')
 city[158] = new Array('66','159','克拉玛依')
 city[159] = new Array('66','160','乌鲁木齐')
 city[160] = new Array('66','161','奎屯')
 city[161] = new Array('66','162','昌吉')
 city[162] = new Array('66','163','吐鲁番')
 city[163] = new Array('66','164','阿克苏')
 city[164] = new Array('66','165','喀什')
 city[165] = new Array('66','166','伊宁/博乐')
 city[166] = new Array('64','167','海晏')
 city[167] = new Array('64','168','同仁')
 city[168] = new Array('64','169','共和')
 city[169] = new Array('64','170','玛沁')
 city[170] = new Array('64','171','玉树')
 city[171] = new Array('64','172','德令哈')
 city[172] = new Array('64','173','门源')
 city[173] = new Array('64','174','河南县')
 city[174] = new Array('64','175','尖扎/泽库')
 city[175] = new Array('64','176','李家峡')
 city[176] = new Array('64','177','乌兰')
 city[177] = new Array('64','178','都兰')
 city[178] = new Array('64','179','天峻')
 city[179] = new Array('64','180','治多')
 city[180] = new Array('64','181','海北')
 city[181] = new Array('64','182','杂多')
 city[182] = new Array('64','183','曲麻莱')
 city[183] = new Array('64','184','龙羊峡')
 city[184] = new Array('64','185','茫崖')
 city[185] = new Array('64','186','贵德')
 city[186] = new Array('64','187','贵南')
 city[187] = new Array('64','188','同德')
 city[188] = new Array('64','189','祁连')
 city[189] = new Array('64','190','刚察')
 city[190] = new Array('64','191','大柴旦')
 city[191] = new Array('64','192','冷湖')
 city[192] = new Array('64','193','达日')
 city[193] = new Array('64','194','玛多')
 city[194] = new Array('64','195','班玛')
 city[195] = new Array('64','196','甘德')
 city[196] = new Array('64','197','久治')
 city[197] = new Array('73','198','荷泽')
 city[198] = new Array('73','199','济南')
 city[199] = new Array('73','200','青岛')
 city[200] = new Array('73','201','淄博')
 city[201] = new Array('73','202','德州')
 city[202] = new Array('73','203','烟台')
 city[203] = new Array('73','204','潍坊')
 city[204] = new Array('73','205','济宁')
 city[205] = new Array('73','206','临沂')
 city[206] = new Array('73','207','滨州')
 city[207] = new Array('73','208','东营')
 city[208] = new Array('73','209','威海')
 city[209] = new Array('73','210','枣庄')
 city[210] = new Array('73','211','日照')
 city[211] = new Array('73','212','莱芜')
 city[212] = new Array('73','213','聊城')
 city[213] = new Array('142','214','滁州')
 city[214] = new Array('142','215','合肥')
 city[215] = new Array('142','216','蚌埠')
 city[216] = new Array('142','217','芜湖')
 city[217] = new Array('142','218','淮南')
 city[218] = new Array('142','219','马鞍山')
 city[219] = new Array('142','220','安庆')
 city[220] = new Array('142','221','宿州')
 city[221] = new Array('142','222','阜阳')
 city[222] = new Array('142','223','黄山')
 city[223] = new Array('142','224','铜陵')
 city[224] = new Array('142','225','宣城(宣州)')
 city[225] = new Array('142','226','六安')
 city[226] = new Array('142','227','巢湖')
 city[227] = new Array('142','228','池州(贵池)')
 city[228] = new Array('106','229','衢州')
 city[229] = new Array('106','230','杭州')
 city[230] = new Array('106','231','湖州')
 city[231] = new Array('106','232','嘉兴')
 city[232] = new Array('106','233','宁波')
 city[233] = new Array('106','234','绍兴')
 city[234] = new Array('106','235','临海(台州)')
 city[235] = new Array('106','236','温州')
 city[236] = new Array('106','237','丽水')
 city[237] = new Array('106','238','金华')
 city[238] = new Array('106','239','舟山')
 city[239] = new Array('147','240','广州')
 city[240] = new Array('147','241','汕尾')
 city[241] = new Array('147','242','潮阳')
 city[242] = new Array('147','243','阳春')
 city[243] = new Array('147','244','揭阳')
 city[244] = new Array('147','245','茂名')
 city[245] = new Array('147','246','江门')
 city[246] = new Array('147','247','韶关')
 city[247] = new Array('147','248','惠州')
 city[248] = new Array('147','249','梅州(梅县)')
 city[249] = new Array('147','250','深圳')
 city[250] = new Array('147','251','珠海')
 city[251] = new Array('147','252','佛山')
 city[252] = new Array('147','253','肇庆')
 city[253] = new Array('147','254','湛江')
 city[254] = new Array('147','255','中山')
 city[255] = new Array('147','256','河源')
 city[256] = new Array('147','257','清远')
 city[257] = new Array('147','258','顺德')
 city[258] = new Array('147','259','潮州')
 city[259] = new Array('147','260','东莞')
 city[260] = new Array('146','261','防城港')
 city[261] = new Array('146','262','南宁')
 city[262] = new Array('146','263','柳州')
 city[263] = new Array('146','264','桂林')
 city[264] = new Array('146','265','梧州')
 city[265] = new Array('146','266','玉林')
 city[266] = new Array('146','267','百色')
 city[267] = new Array('146','268','钦州')
 city[268] = new Array('146','269','河池')
 city[269] = new Array('146','270','北海/合浦')
 city[270] = new Array('157','271','鹰潭')
 city[271] = new Array('157','272','新余')
 city[272] = new Array('157','273','南昌')
 city[273] = new Array('157','274','九江')
 city[274] = new Array('157','275','上饶')
 city[275] = new Array('157','276','抚州')
 city[276] = new Array('157','277','宜春')
 city[277] = new Array('157','278','吉安')
 city[278] = new Array('157','279','赣州')
 city[279] = new Array('157','280','景德镇')
 city[280] = new Array('157','281','萍乡')
 city[281] = new Array('71','282','成都')
 city[282] = new Array('71','283','北碚')
 city[283] = new Array('71','284','攀枝花')
 city[284] = new Array('71','285','自贡')
 city[285] = new Array('71','286','绵阳')
 city[286] = new Array('71','287','南充')
 city[287] = new Array('71','288','达州市')
 city[288] = new Array('71','289','遂宁')
 city[289] = new Array('71','290','华蓥')
 city[290] = new Array('71','291','巴中')
 city[291] = new Array('71','292','开县')
 city[292] = new Array('71','293','梁平')
 city[293] = new Array('71','294','忠县')
 city[294] = new Array('71','295','云阳')
 city[295] = new Array('71','296','奉节')
 city[296] = new Array('71','297','巫山')
 city[297] = new Array('71','298','巫溪')
 city[298] = new Array('71','299','城口')
 city[299] = new Array('71','300','南川')
 city[300] = new Array('71','301','丰都')
 city[301] = new Array('71','302','石柱')
 city[302] = new Array('71','303','垫江')
 city[303] = new Array('71','304','酉阳')
 city[304] = new Array('71','305','秀山')
 city[305] = new Array('71','306','武隆')
 city[306] = new Array('71','307','彭水')
 city[307] = new Array('71','308','泸州')
 city[308] = new Array('71','309','宜宾')
 city[309] = new Array('71','310','内江')
 city[310] = new Array('71','311','乐山')
 city[311] = new Array('71','312','西昌')
 city[312] = new Array('71','313','雅安')
 city[313] = new Array('71','314','康定')
 city[314] = new Array('71','315','马尔康')
 city[315] = new Array('71','316','德阳')
 city[316] = new Array('71','317','广元')
 city[317] = new Array('71','318','理县')
 city[318] = new Array('71','319','汶川')
 city[319] = new Array('71','320','茂县')
 city[320] = new Array('71','321','松潘')
 city[321] = new Array('71','322','南坪')
 city[322] = new Array('71','323','小金')
 city[323] = new Array('148','324','罗甸')
 city[324] = new Array('148','325','贵阳')
 city[325] = new Array('148','326','遵义')
 city[326] = new Array('148','327','安顺')
 city[327] = new Array('148','328','都匀')
 city[328] = new Array('148','329','凯里')
 city[329] = new Array('148','330','铜仁')
 city[330] = new Array('148','331','毕节')
 city[331] = new Array('148','332','六盘水')
 city[332] = new Array('148','333','兴义')
 city[333] = new Array('148','334','平坝')
 city[334] = new Array('148','335','紫云')
 city[335] = new Array('148','336','关岭')
 city[336] = new Array('148','337','镇宁')
 city[337] = new Array('148','338','普定')
 city[338] = new Array('148','339','贵定')
 city[339] = new Array('148','340','福泉')
 city[340] = new Array('148','341','翁安')
 city[341] = new Array('148','342','三都')
 city[342] = new Array('148','343','荔波')
 city[343] = new Array('148','344','独山')
 city[344] = new Array('148','345','平塘')
 city[345] = new Array('148','346','惠水')
 city[346] = new Array('148','347','龙里')
 city[347] = new Array('148','348','榕江')
 city[348] = new Array('148','349','长顺')
 city[349] = new Array('154','350','武汉')
 city[350] = new Array('154','351','襄樊')
 city[351] = new Array('154','352','鄂州')
 city[352] = new Array('154','353','孝感')
 city[353] = new Array('154','354','麻城')
 city[354] = new Array('154','355','黄石')
 city[355] = new Array('154','356','咸宁')
 city[356] = new Array('154','357','沙市')
 city[357] = new Array('154','358','宜昌')
 city[358] = new Array('154','359','恩施')
 city[359] = new Array('154','360','十堰')
 city[360] = new Array('154','361','随州')
 city[361] = new Array('154','362','荆门')
 city[362] = new Array('154','363','洪湖')
 city[363] = new Array('153','364','岳阳')
 city[364] = new Array('153','365','长沙')
 city[365] = new Array('153','366','湘潭')
 city[366] = new Array('153','367','株洲')
 city[367] = new Array('153','368','衡阳')
 city[368] = new Array('153','369','郴州')
 city[369] = new Array('153','370','常德')
 city[370] = new Array('153','371','益阳')
 city[371] = new Array('153','372','娄底')
 city[372] = new Array('153','373','邵阳')
 city[373] = new Array('153','374','吉首')
 city[374] = new Array('153','375','张家界')
 city[375] = new Array('153','376','怀化')
 city[376] = new Array('153','377','永州')
 city[377] = new Array('68','378','西安')
 city[378] = new Array('68','379','咸阳')
 city[379] = new Array('68','380','延安')
 city[380] = new Array('68','381','榆林')
 city[381] = new Array('68','382','渭南')
 city[382] = new Array('68','383','商洛(商州)')
 city[383] = new Array('68','384','安康')
 city[384] = new Array('68','385','汉中')
 city[385] = new Array('68','386','宝鸡')
 city[386] = new Array('68','387','铜川')
 city[387] = new Array('145','388','福州')
 city[388] = new Array('145','389','厦门')
 city[389] = new Array('145','390','宁德')
 city[390] = new Array('145','391','莆田')
 city[391] = new Array('145','392','泉州')
 city[392] = new Array('145','393','漳州')
 city[393] = new Array('145','394','龙岩')
 city[394] = new Array('145','395','三明')
 city[395] = new Array('145','396','南平')
 city[396] = new Array('144','397','临夏')
 city[397] = new Array('144','398','兰州')
 city[398] = new Array('144','399','定西')
 city[399] = new Array('144','400','平凉')
 city[400] = new Array('144','401','庆阳')
 city[401] = new Array('144','402','武威')
 city[402] = new Array('144','403','张掖')
 city[403] = new Array('144','404','酒泉')
 city[404] = new Array('144','405','天水')
 city[405] = new Array('144','406','武都')
 city[406] = new Array('144','407','甘南州')
 city[407] = new Array('144','408','白银')
 city[408] = new Array('144','409','武山')
 city[409] = new Array('109','410','景洪')
 city[410] = new Array('109','411','瑞丽')
 city[411] = new Array('109','412','昭通')
 city[412] = new Array('109','413','昆明')
 city[413] = new Array('109','414','大理')
 city[414] = new Array('109','415','个旧')
 city[415] = new Array('109','416','曲靖')
 city[416] = new Array('109','417','保山')
 city[417] = new Array('109','418','文山')
 city[418] = new Array('109','419','玉溪')
 city[419] = new Array('109','420','楚雄')
 city[420] = new Array('109','421','思茅')
 city[421] = new Array('109','422','东川')
 city[422] = new Array('109','423','耿马')
 city[423] = new Array('109','424','福贡')
 city[424] = new Array('109','425','中甸')
 city[425] = new Array('147','426','汕头')
 city[426] = new Array('1','427','台北')
 city[427] = new Array('1','428','桃园')
 city[428] = new Array('1','429','苗栗')
 city[429] = new Array('1','430','台中')
 city[430] = new Array('1','431','南投')
 city[431] = new Array('1','432','云林')
 city[432] = new Array('1','433','台南')
 city[433] = new Array('1','434','高雄')
 city[434] = new Array('1','435','屏东')
 city[435] = new Array('1','439','台东')
 city[436] = new Array('1','1350','基隆')
 city[437] = new Array('1','1351','新竹')
 city[438] = new Array('1','1352','宜兰')
 city[439] = new Array('1','1353','花莲')
 city[440] = new Array('1','1354','彰化')
 city[441] = new Array('1','1355','嘉义')
 city[442] = new Array('1','1356','外岛')
 city[443] = new Array('154','1357','荆州')
 city[444] = new Array('154','1358','黄冈')

 
 function FullProvince(obj)
 {
  obj.length = 0;
  obj.options[0] = new Option('-- 选择省市--','');

  for(i=0;i<province.length;i++)
  {
   obj.options[obj.length] = new Option(province[i][1],province[i][0])
  }
 }

 function FullCitys(obj,pid)
 {
  obj.length = 0;
  obj.options[0] = new Option('-- 选择城镇--','');

  for(i=0;i<city.length;i++)
  {
   if(city[i][0]==pid)
   {
    obj.options[obj.length] = new Option(city[i][2],city[i][1])
   }   
  }
 } 

}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:34415次
    • 积分:484
    • 等级:
    • 排名:千里之外
    • 原创:10篇
    • 转载:0篇
    • 译文:0篇
    • 评论:28条
    最新评论