Traditional Culture Encyclopedia - Hotel reservation - The drop-down menu of ASP controls the content of another drop-down menu.

The drop-down menu of ASP controls the content of another drop-down menu.

Below is the drop-down list of China provinces and cities I made. You can save it as an asp file and then execute it to see the effect.

& lttable align = " center " cell padding = " 0 " cell spacing = " 0 " >

& ltform name = " form 1 " method = " post " action = " " onSubmit = " return false " >

& lttr & gt

& lttd width="90" height="20 " >

< select style = "width: 90" name = "province" size=" 1" id= "province" onchange = "change city (document.form1.province. Options [document.form 1. province. Value) ">

& ltOption value= "Please select a province" selected & gt Please select a province.

& lt%allprovince= "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.

every province = split(all province,",")

For i=0 to ubound (every province)% >

& lt option value = "<% = everyprovince (I)% >><% = everyprovince (I)% > & lt/option & gt;

& lt% next % & gt

& lt/select & gt;

& lt/TD & gt;

& lttd width=" 10 1 " >& ltselect name = " city " style = " width:90px " size = " 1 " id = " city " & gt;

& lt Selected Options & gt Please select a city.

& lt/select & gt;

& lt/TD & gt;

& lt/tr & gt;

& lt/form & gt;

& lt/table & gt;

& lt scripting language = "javascript">

/* provinces and cities display */

var each city = new Array();

var TC num = new Array();

& lt%allpc= "Beijing | Dongcheng Xicheng Chongwen Xuanwu Chaoyang Fengtai Shijingshan Haidian Mentougou Fangshan Tongzhou Shunyi Changping Daxing Pinggu Huairou Miyun Yanqing * Shanghai | Huangpu Luwan Xuhui Changning Jing 'an Putuo Zhabei Hongkou Yangpu. Peace Dongli Hedong Xiqing Hexi Jinnan Nankai Beichen Hebei Wuqing Red Tanggu Hangu Dagang Ninghe Jinghai Baodi County * Chongqing | Wanzhou Fuling Yuzhong Dadukou Jiangbei Shapingba Jiulongpo South Bank Beibei Wansheng Shuangcheng Yubei Banan Qianjiang Changshou Qijiang Tongnan Tongliang Dazu Rongchang Bishan Liangping Chengkou Fengdu Dianjiang Shijiazhuang Handan Xingtai Baoding Chengde Langfang Tangshan Qinhuangdao Cangzhou Hengshui * Shanxi | Taiyuan Datong Yangquan Changzhi Jincheng Shuozhou Lvliang Xinzhou Linfen Yuncheng * Inner Mongolia | Hohhot Baotou Wuhai Chifeng Hulunbeier League Alashan League Zhejiang Shenyang Dalian Anshan Fushun Benxi Dandong Jinzhou Yingkou Fuxin Liaoyang Panjin Tieling Chaoyang Huludao * Jilin | Changchun Jilin Siping Liaoyuan Tonghua Baishan Songyuan Baicheng Yanbian * Heilongjiang | Harbin Qiqihar Mudanjiang Jiamusi Suihua Daqing Nanjing Zhenjiang Suzhou Nantong Yangzhou Xuzhou Lianyungang Changzhou Wuxi Suqian Taizhou Huai 'an * Zhejiang Hangzhou Ningbo Wenzhou Jiaxing Huzhou Shaoxing Jinhua Quzhou Taizhou Lishui * Anhui Hefei Wuhu Bengbu Maanshan Huaibei Tongling Fuzhou Xiamen Putian Sanming Quanzhou Zhangzhou Nanping Longyan Ningde * Jiangxi | Nanchang Jingdezhen Jiujiang yingtan Pingxiang Xinyu Ganzhou Ji 'an Yichun Fuzhou Shangrao * Shandong | Jinan Qingdao Zibo Zaozhuang Dongying Weifang Jining Taian Zhengzhou Kaifeng Luoyang Pingdingshan Anyang Hebi Xinxiang Jiaozuo Puyang Xuchang Luohe Sanmenxia Nanyang Shangqiu Xinyang Zhoukou Zhumadian Jiyuan * Hubei | Wuhan Yichang Jingzhou Xiangfan Huangshi Jingmen Huanggang Shiyan Enshi Qianjiang Tianmen Xiantao Suizhou Changsha Changde Zhuzhou Hengyang Yiyang Loudi Huaihua Zhangzhou Yongzhou Xiangxi Zhangjiajie * Guangdong | Guangzhou Shenzhen Shantou Zhongshan Foshan Shaoguan Jiangmen Zhanjiang Maoming Zhaoqing Huizhou Shanwei Heyuan Yangjiang Nanning Guilin Wuzhou Beihai Fangchenggang Qinzhou Yulin Nanning Liuzhou Hezhou Baise Hechi * Hainan Haikou Sanya * Mianyang Deyang Zigong Panzhihua Guangyuan Neijiang Leshan Nanchong Yibin Guang 'an Dachuan Ya 'an Kunming Dali Qujing Yuxi Zhaotong Chuxiong Honghe Wenshan Simao Xishuangbanna Baoshan Dehong Lijiang Nujiang Diqing Lincang * Tibet | Lhasa Shigatse Shannan Linzhi Changdu Arinagqu * Shaanxi | Xi 'an Baoji Xianyang Tongchuan Lanzhou Jiayuguan Jinchang Baiyin Tianshui Jiuquan Zhangye Dingxi Longnan Pingliang Qingyang Linxia Gannan * Ningxia | Yinchuan Shizuishan Wuzhong Guyuan * Qinghai | Qinghai Xining Haidong Hainan Haibei Huangnan Yushu Guoluo Haixi * Xinjiang | Urumqi Macau | * Taiwan Province Province | Taipei Kaohsiung Taichung Tainan Pingtung Nantou Yunlin Hsinchu Zhanghua Miaoli Chiayi Hualien Taoyuan Yilan Keelung Taitung Jinmen Mazu Penghu "

allp=split(allpc," * ")

For i=0 to the lower bound (allp)

pc=split(allp(i)," | ")

eachcity=split(pc( 1),"^")%>;

Every city [<: % = i % & gt]= new Array();

& lt%for j=0 to ubound (per city)%>

Every city [<: % = i % & gt][& lt; % = j% & gt]= new array ("<% = per city (j)% >," & lt%=pc(0)% >);

& lt% next % & gt

TC num[& lt; % = i % & gt]= & lt; %=ubound (per city)%>;;

& lt% Next

TP num = ubound(allp)% & gt;

Function change city (provincial value) {

/* When the value of the selected large category list is not empty, first empty all items in the small category drop-down list. Otherwise, the items in the small category list will overlap. At the same time, the value of initialization option is 0 */

document . form 1 . city . length = 0;

//Write out the small class corresponding to the requested large class circularly.

for(I = 0; I<=<% = tpnum%>;; i++){

for(j = 0; j & lt= TC num[I]; j++){

if(province value = = each city[I][j][ 1]){

document . form 1 . city . options[document . form 1 . city . length]= new Option(eachcity[i][j][0],each city[I][j][0],""," ");

/* Define a new option object and assign a value. The index value of the option starts from 0. The new Option object has four properties, corresponding to the text string, value, default value Select and selected. Only the first and second ones are used here. */

}

}

}

}

& lt/script & gt;