Implementation of three-level linkage drop-down menu in China

Source: Internet
Author: User

Recently, the three-level linkage drop-down menu in China is needed. Although it has been implemented using the company's framework, I am confused about it and found the relevant code on the Internet, the main data and functions are implemented in the JS file. The region data found on the internet is incomplete and needs to be added by yourself. Although it is different from the Code implemented by the company's framework, put the code first. You can check it later. You can also check it!

1. The first is the JS file (area. JS ):

View code

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", ["Anhui", "Beijing", "Fujian", "Gansu", "Guangdong", "Guangxi", "Guizhou", "Hainan ", "Hebei", "Henan", "Heilongjiang", "Hubei", "Hunan", "Jilin", "Jiangsu", "Jiangxi", "Liaoning", "Inner Mongolia ", "Ningxia", "Qinghai", "Shandong", "Shanxi", "Shaanxi", "Shanghai", "Sichuan", "Tianjin", "Tibet", "Xinjiang ", "Yunnan", "Zhejiang", "Chongqing"]);

Dsy. add ("0_0", ["Anqing", "Bengbu", "Chaohu", "Chizhou", "Chuzhou", "Fuyang", "Hefei", "Huaibei ", "Huainan", "Huangshan", "lu'an", "ma'anshan", "Suzhou", "Tongling", "Wuhu", "xuancheng", "Zhuzhou"]);
Dsy. add ("0_0_0", ["Anqing City", "huaining county", "Qianshan County", "susong county", "Taihu County", "Tongcheng City", "Wangjiang County", "Yuexi County ", "shuyang county"]);
Dsy. Add ("0_0_1", ["Bengbu City", "Guzhen County", "Huaiyuan County", "Wuhe County"]);
Dsy. Add ("0_0_2", ["Chaohu City", "Hanshan county", "counties", "Lujiang county", "Wuwei County"]);
Dsy. Add ("0_0_3", ["Chizhou city", "Dongzhi County", "Qingyang county", "Shitai county"]);
Dsy. Add ("0_0_4", ["Chuzhou City", "Dingyuan county", "Fengyang county", "lai'an county", "mingguang City", "quanjiao county", "tianchang City"]);
Dsy. Add ("0_0_5", ["Funan county", "Fuyang City", "jieshou City", "Linquan county", "Taihe County", "Yingshang county"]);
Dsy. Add ("0_0_6", ["Changfeng county", "feidong county", "Feixi county"]);
Dsy. Add ("0_0_7", ["Huai Yu", "Xi County"]);
Dsy. Add ("0_0_8", ["Fengtai county", "HuaiNan City"]);
Dsy. Add ("0_0_9", ["Huangshan city", "Qimen County", "Xiuning County", "PiXian county", "PiXian county"]);
Dsy. Add ("0_0_10", ["huoqiu county", "Huoshan county", "jinzhai county", "Lu 'an city", "Shou County", "Shucheng County"]);
Dsy. Add ("0_0_11", ["dangtu county", "Maanshan City"]);
Dsy. Add ("0_0_12", ["lingbi county", "Suzhou City", "Xiao County", "Si county", "Shan county"]);
Dsy. Add ("0_0_13", ["Tongling City", "Tongling county"]);
Dsy. Add ("0_0_14", ["fanchang county", "Nanling County", "Wuhu City", "Wuhu County"]);
Dsy. Add ("0_0_15", ["guangde county", "Jixi county", "langxi county", "Ningguo city", "xuancheng City", "Jing county", "jude county"]);
Dsy. Add ("0_0_16", ["Lixin County", "mengcheng county", "guoyang county", "danzhou City"]);

Dsy. Add ("0_1", ["Beijing"]);
Dsy. Add ("0_00000", ["Beijing", "Miyun county", "Yanqing County"]);

Dsy. add ("0_2", ["Fuzhou", "Longyan", "Nanping", "Ningde", "Putian", "Quanzhou", "Sanming", "Xiamen ", "Zhangzhou"]);
Dsy. add ("0_2_0", ["Changle City", "Fuqing City", "Fuzhou City", "Lianjiang County", "Luoyuan county", "minhou county", "minqing county", "Pingtan county ", "Yongtai county"]);
Dsy. Add ("0_2_1", ["changting county", "Lian Cheng county", "Longyan city", "shanghang county", "Wuping County", "Yongding County", "zhangping City"]);
Dsy. add ("0_2_2", ["Changzhi county", "Jianyang city", "jianou City", "Nanping city", "Pucheng county", "Shaowu City", "Shunchang county", "Songxi county ", "Wuyishan City", "Political and county"]);
Dsy. add ("0_2_3", ["Fu 'an city", "Fu Ding City", "Gutian County", "Ningde City", "Pingnan county", "shouning county", "xiapu county", "Zhou Ning county ", "jingrong county"]);
Dsy. Add ("0_2_4", ["Putian City", "Xianyou County"]);
Dsy. add ("0_2_5", ["Anxi County", "Dehua County", "Hui 'an county", "Jinmen county", "Jinjiang City", "Nan 'an city", "Quanzhou City", "Shi City ", "Yongchun county"]);
Dsy. add ("0_2_6", ["Datian County", "jianning county", "jiangle county", "Mingxi County", "Ninghua County", "qingliu county", "Sanshu", "Sha county ", "tyining county", "yong'an City", "Youxi County"]);
Dsy. Add ("0_2_7", ["Xiamen City"]);
Dsy. add ("0_2_8", ["Changtai county", "Dongshan county", "Hua 'an county", "Longhai city", "Nanjing County", "Pinghe County", "Yunyi county", "Zhangpu County ", "Zhangzhou City", "Lu 'an county"]);

Dsy. add ("0_3", ["Silver", "Dingxi", "Gannan Tibetan Autonomous Prefecture", "Jiayuguan", "Jinchang", "Jiuquan", "Lanzhou ", "Linxia Hui Autonomous Prefecture", "Longnan", "Pingliang", "Qingyang", "Tianshui", "Wuwei", "Hui"]);
Dsy. Add ("0_3_0", ["Baiyin City", "huining county", "Jingtai county", "Jingyuan County"]);
Dsy. Add ("0_3_1", ["Dingxi County", "Linyi county", "Longxi County", "Tongwei County", "Weiyuan county", "zhangxian", "Min county"]);
Dsy. add ("0_3_2", ["diebu county", "partner city", "lintan county", "luqu county", "Maqu County", "xia He County", "Zhouqu county ", "zhuoni county"]);
Dsy. Add ("0_3_3", ["Jiayuguan City"]);
Dsy. Add ("0_3_4", ["Jinchang city", "yongchang county"]);
Dsy. add ("0_3_5", ["Aksai Kazakh Autonomous County", "Anxi County", "Dunhuang City", "Golden Tower county", "Jiuquan City", "Suzhou North mongolia Autonomous County ", "Yumen City"]);
Dsy. Add ("0_3_6", ["kelan county", "Lanzhou City", "Yongdeng County", "Yuzhong county"]);
Dsy. add ("0_3_7", ["Dongxiang Autonomous County", "Guanghe County", "hezheng county", "jishishan Security Dongxiang Sara Autonomous County", "kangle county", "Linxia City", "Linxia county ", "yongjing county"]);
Dsy. add ("0_3_8", ["Cheng county", "Hui County", "Kang County", "Li County", "liangdang county", "Wen County", "Wudu County", "Xi County ", "changchang county"]);
Dsy. Add ("0_3_9", ["chongxin county", "Huating county", "Jingning County", "lingtai county", "Pingliang city", "zhuanglang county", "Jingchuan county"]);
Dsy. add ("0_3_10", ["Heshui county", "Huachi County", "Huan county", "Ning county", "Qingcheng county", "Qingyang City", "zhenyuan county ", "zhengning county"]);
Dsy. Add ("0_3_11", ["ganggu county", "qin'an county", "Qingshui county", "Tianshui city", "Wushan County", "Zhangjiachuan Hui Autonomous County"]);
Dsy. Add ("0_3_12", ["Gulang County", "Minqin County", "Tianzhu Tibetan Autonomous County", "Wuwei City"]);
Dsy. Add ("0_3_13", ["Gaotai County", "Linze county", "Minle County", "Shandan county", "sunnan yugu Autonomous County", "Changzhi City"]);

Dsy. add ("0_4", ["Chaozhou", "Dongguan", "Foshan", "Guangzhou", "Heyuan", "Huizhou", "Jiangmen", "Jieyang ", "Maoming", "Meizhou", "Qingyuan", "Shantou", "Shanwei", "Shaoguan", "Shenzhen", "Yangjiang", "yunfu", "Zhanjiang ", "Zhaoqing", "Zhongshan", "Zhuhai"]);
Dsy. Add ("0_4_0", ["Chao 'an county", "Chaozhou City", "raoping county"]);
Dsy. Add ("0_4_1", ["Dongguan City"]);
Dsy. Add ("0_4_2", ["Foshan City"]);
Dsy. Add ("0_4_3", ["Conghua City", "Guangzhou City", "zengcheng City"]);
Dsy. Add ("0_4_4", ["Dongyuan county", "Heping county", "Heyuan City", "Lianping County", "Longchuan County", "Zijin County"]);
Dsy. Add ("0_4_5", ["boluo county", "Huidong county", "huiyang City", "Huizhou City", "Longmen county"]);
Dsy. Add ("0_4_6", ["n'ping City", "heshan City", "Jiangmen City", "Kaiping city", "Taishan City"]);
Dsy. Add ("0_4_7", ["Huilai county", "jiedong county", "jiexi county", "Jieyang City", "Puning City"]);
Dsy. Add ("0_4_8", ["dianbai county", "Gaozhou City", "huazhou City", "Maoming City", "Xinyi city"]);
Dsy. add ("0_4_9", ["dazhi county", "Fengshun County", "Lingling county", "Mei County", "Meizhou City", "pingyuan county", "Wuhua County ", "xingning City"]);
Dsy. add ("0_4_10", ["Fogang county", "Liannan Yao Autonomous County", "Guizhou Zhuang Yao Autonomous County", "Lianzhou City", "Qingxin county", "Qingyuan City", "Yangshan county ", "Yingde City"]);
Dsy. Add ("0_4_11", ["Chaoyang City", "Chenghai City", "Nanao county", "Shantou City"]);
Dsy. Add ("0_4_12", ["Haifeng county", "Lufeng City", "luhe county", "Shanwei City"]);
Dsy. add ("0_4_13", ["Lechang city", "Nanxiong City", "Qujiang County", "renhua county", "Ruyuan Yao Autonomous County", "Shaoguan City", "Shixing County ", "Wengyuan county", "Xinfeng County"]);
Dsy. Add ("0_4_14", ["Shenzhen City"]);
Dsy. Add ("0_4_15", ["Yangchun City", "yangdong county", "Yangjiang City", "Yangxi county"]);
Dsy. Add ("0_4_16", ["Baoding City", "Xinxing county", "Yunan county", "Yun 'an county", "Yun Fu City"]);
Dsy. Add ("0_4_17", ["Leizhou City", "Lianjiang City", "Suixi county", "Wuchuan City", "Xuwen County", "Zhanjiang city"]);
Dsy. Add ("0_4_18", ["Deqing County", "fengkai county", "gaoyao City", "guangning county", "huaiji county", "sihui City", "Zhaoqing City"]);
Dsy. Add ("0_4_19", ["Zhongshan City"]);
Dsy. Add ("0_4_20", ["Zhuhai"]);

Dsy. add ("0_5", ["Baise", "Beihai", "chongzuo", "Fangchenggang", "Guilin", "Guigang", "Hechi", "Hezhou ", "Laibin", "Liuzhou", "Nanning", "Qinzhou", "Wuzhou", "Yulin"]);
Dsy. add ("0_5_0", ["Baise City", "Debao county", "Jinxi county", "Leye County", "Lingyun county", "longlin Autonomous County", "Napo county ", "Pingguo county", "Tian Dong county", "Tian Lin County", "Tian YANG county", "Xi Lin County"]);
Dsy. Add ("0_5_1", ["Beihai City", "Hepu county"]);
Dsy. Add ("0_5_2", ["chongzuo City", "daxin county", "Fusui county", "longzhou county", "Ningming county", "Pingxiang City", "tianyao county"]);
Dsy. Add ("0_5_3", ["Dongxing City", "Fangchenggang city", "shangsi county"]);
Dsy. add ("0_5_4", ["Gongcheng Yao Autonomous County", "guanyang county", "Guilin City", "Lipu county", "lingui county", "Lingchuan County", "longsheng Autonomous County ", "Pingle county", "Quanzhou County", "PiXian county", "Yangshuo county", "Yongfu county", "resource county"]);
Dsy. Add ("0_5_5", ["Guiping city", "Guigang City", "Pingnan county"]);
Dsy. add ("0_5_6", ["Bama Yao Autonomous County", "Dahua Yao Autonomous County", "donglan county", "Duan Yao Autonomous County", "fengshan county", "Hechi City ", "huanjiang maonan Autonomous County", "luocheng Yi Autonomous County", "Nandan county", "Tianye county", "Yizhou City"]);
Dsy. Add ("0_5_7", ["fuchuan Yao Autonomous County", "Hezhou City", "Zhaoping county", "Zhongshan County"]);
Dsy. Add ("0_5_8", ["heshan City", "Jinxiu Yao Autonomous County", "Laibin City", "wuxuan county", "Xiangzhou county", "Xincheng County"]);
Dsy. add ("0_5_9", ["Liucheng county", "Liujiang county", "Liuzhou City", "luzhai county", "rong 'an county", "Rongshui Miao Autonomous County ", "Sanjiang Dong Autonomous County"]);
Dsy. add ("0_5_10", ["Binyang county", "Heng county", "Long 'an county", "Ma shan county", "Nanning City", "shanglin county", "Wuming county ", "Suining county"]);
Dsy. Add ("0_5_11", ["lingshan county", "pubei county", "Qinzhou City"]);
Dsy. Add ("0_5_12", ["Cangwu county", "mengshan county", "Teng county", "Wuzhou City", "CEN Xi City"]);
Dsy. Add ("0_5_13", ["Beiliu City", "Bobai county", "Luchuan county", "Rongxian", "xingye county", "Yulin City"]);
Dsy. add ("0_6", ["Anshun", "Bijie", "Guiyang", "liupanshui", "Qiandongnan Miao and Dong Autonomous Prefecture", "Qiannan Buyi and Miao Autonomous Prefecture ", "Buyi Miao Autonomous Prefecture of Southwestern Guizhou Province", "Tongren", "Zunyi"]);
Dsy. add ("0_6_0", ["Anshun City", "Guanling Buyi Miao Autonomous County", "pingba county", "Puding county", "zhenning Buyi Miao Autonomous County ", "Ziyun Miao Buyi Autonomous County"]);
Dsy. add ("0_6_1", ["Bijie City", "Dafang county", "Hezhang County", "Jinsha County", "nayong county", "qianxi county", "Weining Yi Hui and Miao Autonomous County ", "Zhijin county"]);
Dsy. Add ("0_6_2", ["Guiyang City", "KaiYang county", "Qingzhen City", "Xifeng county", "Xiuwen county"]);
Dsy. Add ("0_6_3", ["liupanshui City", "liuzhi Special Zone", "Pan County", "suicheng county"]);
Dsy. add ("0_6_4", ["conjiang county", "Danzhai county", "huangping county", "Jianhe county", "Jinping County", "Kerry City", "leishan county", "Liping county ", "Ma Jiang county", "Sansui county", "Shi Bing County", "Taijiang county", "Tianzhu County", "zhenyuan county", "cengong county", "Rongjiang county"]);
Dsy. add ("0_6_5", ["changshun county", "Duyun City", "dushanshan county", "Fuquan city", "Guizhou county", "huishui county", "Libo County", "longli county ", "Luodian county", "Pingtang county", "Sandu aquarium Autonomous County", "Lu 'an county"]);
Dsy. add ("0_6_6", ["Anlong County", "cheheng county", "Pu 'an county", "Qinglong County", "wangyi county", "Xingren county", "Xingyi City ", "Zhenfeng County"]);
Dsy. add ("0_6_7", ["Dejiang county", "Jiangkou county", "Shiji county", "Sinan County", "Songtao Miao Autonomous County", "Tongren City", "Wanshan SAR ", "YanHe Tujia Autonomous County", "Yinjiang Tujia and Miao Autonomous County", "yuping Dong Autonomous County"]);
Dsy. add ("0_6_8", ["Chishui City", "daozhen Yi Miao Autonomous County", "Fenggang county", "renhuai City", "suyang county", "Tongzi county ", "Wuchuan Yi Miao Autonomous County", "xishui county", "yuqing county", "Zheng 'an county", "Zunyi City", "Zunyi county", "meitan county"]);

Dsy. add ("0_7", ["Baisha Li Autonomous County", "Baoting Li and Miao Autonomous County", "Changjiang Li Autonomous County", "chengmai county", "ding 'an county", "Dongfang ", "Haikou", "Ledong Li Autonomous County", "Lingshui Li Autonomous County", "Qionghai", "qiongzhong Li and Miao Autonomous County", "Sanya", "tunchang county ", "Wanning", "Wenchang", "Wuzhishan", "Zhuzhou"]);
Dsy. Add ("0_7_0", ["Baisha Li Autonomous County"]);
Dsy. Add ("0_7_1", ["Baoting Li and Miao Autonomous County"]);
Dsy. Add ("0_7_2", ["Changjiang Li Autonomous County"]);
Dsy. Add ("0_7_3", ["chengmai county"]);
Dsy. Add ("0_7_4", ["ding 'an county"]);
Dsy. Add ("0_7_5", ["oriental city"]);
Dsy. Add ("0_7_6", ["Haikou City"]);
Dsy. Add ("0_7_7", ["Ledong Li Autonomous County"]);
Dsy. Add ("0_7_8", ["Lingao county"]);
Dsy. Add ("0_7_9", ["Lingshui Li Autonomous County"]);
Dsy. Add ("0_7_10", ["Qionghai City"]);
Dsy. Add ("0_7_11", ["qiongzhong Li and Miao Autonomous County"]);
Dsy. Add ("0_7_12", ["Sanya City"]);
Dsy. Add ("0_7_13", ["tunchang county"]);
Dsy. Add ("0_7_14", ["Wanning City"]);
Dsy. Add ("0_7_15", ["Wenchang city"]);
Dsy. Add ("0_7_16", ["Wuzhishan City"]);
Dsy. Add ("0_7_17", [""]);

Dsy. add ("0_8", ["Baoding", "Cangzhou", "Chengde", "Handan", "Hengshui", "Langfang", "Qinhuangdao", "Shijiazhuang ", "Tangshan", "Xingtai", "Zhangjiakou"]);
Dsy. add ("0_8_0", ["Anguo city", "Anxin County", "Baoding City", "Boye county", "dingxing county", "Dingzhou City", "Fuping County", "Gaobeidian City ", "Gaoyang County", "mancheng county", "qingting county", "quyang county", "Rongcheng county", "shunping county", "Tang county", "Wangdu County", "Xiong county", "Xushui County ", "Yi County", "lushui county", "luyuan county", "Shengzhou City", "zhuxian county"]);
Dsy. add ("0_8_1", ["botou City", "Cang county", "Cangzhou City", "Dongguang County", "Haixing county", "hejian City", "Huangpi City ", "mengcun Hui Autonomous County", "nanpi county", "qingxian county", "Renqiu City", "Suning county", "Wuqiao County", "Xian County", "Yanshan County"]);
Dsy. add ("0_8_2", ["Chengde City", "Chengde county", "Fengning Manchu Autonomous County", "Kuan Cheng Manchu Autonomous County", "Longhua county", "Luanping county", "pingquan county ", "weichang Manchu and Mongolian Autonomous County", "Xinglong County"]);
Dsy. add ("0_8_3", ["Cheng 'an county", "cixian county", "Daming county", "feixiang county", "Guantao County", "Guangping county", "Handan city", "PiXian county ", "Jize county", "linzhang county", "Qiu county", "Qu Zhou County", "Shen county", "Wei County", "Wu 'an city", "Yongnian county"]);
Dsy. add ("0_8_4", ["Anping County", "Fucheng County", "hometown county", "Hengshui City", "Jizhou city", "Jing county", "Raoyang county", "Shenzhou City ", "wuqiang county", "Wuzhi county", "zaoqiang county"]);
Dsy. add ("0_8_5", ["Bazhou City", "Dachang Hui Autonomous County", "Dacheng county", "Gu 'an county", "Langfang City", "Sanhe City", "Wen 'an county ", "Xianghe county", "Yongqing county"]);
Dsy. Add ("0_8_6", ["Changli County", "funning county", "Lulong county", "Qinhuangdao City", "Qinglong Manchu Autonomous County"]);
Dsy. add ("0_8_7", ["gaoyi county", "Jinzhou City", "Jingyi county", "lingshou county", "Luquan City", "Pingshan County", "shenzhe county", "Shijiazhuang City ", "Wuji County", "Xinji City", "Xinle City", "xingtang county", "Yuanshi county", "Zanhuang county", "Zhao County", "Zhengding County", "Zhucheng City ", "Luancheng County"]);
Dsy. add ("0_8_8", ["leting county", "luannan county", "luxian county", "Qian 'an city", "Qian Xi County", "Tang Hai county", "Tangshan City", "Yutian County ", "zunhua City"]);
Dsy. add ("0_8_9", ["Bai Xiang county", "Guang Zong county", "Julu county", "Lincheng County", "linxi county", "longyao county", "Nangong City", "Nanhe county ", "neiqiu county", "ningjin county", "Pingxiang county", "Qinghe county", "Ren County", "shahe City", "Wei County", "Xinhe county", "Xingtai City ", "Xingtai county"]);
Dsy. add ("0_8_10", ["Chicheng County", "Chongli county", "Gu Yuan County", "Huai 'an county", "Huai Lai county", "Kang Bao county", "Shang Yi County", "Wan Quan county ", "Wei County", "Xuan Hua county", "Yangyuan county", "Zhangbei County", "Zhangjiakou City", "Luhan county"]);

Dsy. add ("0_9", ["Anyang", "hebi", "Jiyuan", "Jiaozuo", "Kaifeng", "Luoyang", "Nanyang", "Pingdingshan ", "Sanmenxia", "Shangqiu", "Xinxiang", "Xinyang", "xuchang", "Zhengzhou", "Zhoukou", "Zhumadian", "Luohe ", "Puyang"]);
Dsy. Add ("0_9_0", ["Anyang city", "Anyang county", "Slippery county", "Linzhou City", "nehuang county", "tangyin county"]);
Dsy. Add ("0_9_1", ["", "hebi City", "PiXian county", "PiXian county"]);
Dsy. Add ("0_9_2", ["Jiyuan City"]);
Dsy. Add ("0_9_3", ["boai county", "Jiaozuo City", "mengzhou City", "qinyang City", "Wen County", "Wuyi county ",

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.