神秘的 J2ee 殿堂

·古之学者必有师·做学者亦要做师者·FIGHTING·

js省市二级联动

js省市二级联动实习方法一:
<html>
<head>
</head>
<body>省:
<select id="shen" onChange="goGo(this.options.selectedIndex)">
<option value="直辖市" selected>直辖市</option>
<option value="湖北">湖北</option>
<option value="河北">河北</option>
<option value="山西">山西</option>
<option value="内蒙古">内蒙古</option>
<option value="辽宁">辽宁</option>
<option value="吉林">吉林</option>
<option value="黑龙江">黑龙江</option>
<option value="江苏">江苏</option>
<option value="浙江">浙江</option>
<option value="安徽">安徽</option>
<option value="福建">福建</option>
<option value="江西">江西</option>
<option value="山东">山东</option>
<option value="河南">河南</option>
<option value="海南">海南</option>
<option value="广东">广东</option>
<option value="广西">广西</option>
<option value="湖南">湖南</option>
<option value="四川">四川</option>
<option value="贵州">贵州</option>
<option value="云南">云南</option>
<option value="西藏">西藏</option>
<option value="陕西">陕西</option>
<option value="甘肃">甘肃</option>
<option value="宁夏">宁夏</option>
<option value="青海">青海</option>
<option value="新疆">新疆</option>
</select>
市:
<select id="city">
<option value="北京" selected>北京</option>
<option value="上海">上海</option>
<option value="天津">天津</option>
<option value="重庆">重庆</option>
</select>

<script>
<!-- 
var groups=document.getElementById("shen").options.length;
var group=new Array(groups);
for (i=0; i<groups; i++
group[i]
=new Array();
group[
0][0]=new Option("北京","北京");
group[
0][1]=new Option("上海","上海");
group[
0][2]=new Option("天津","天津");
group[
0][3]=new Option("重庆","重庆");
group[
1][0]=new Option("武汉","武汉");
group[
1][1]=new Option("鄂州","鄂州");
group[
1][2]=new Option("孝感","孝感");
group[
1][3]=new Option("黄冈","黄冈");
group[
1][4]=new Option("黄石","黄石");
group[
1][5]=new Option("咸宁","咸宁");
group[
1][6]=new Option("沙市","沙市");
group[
1][7]=new Option("宜昌","宜昌");
group[
1][8]=new Option("恩施","恩施");
group[
1][9]=new Option("十堰","十堰");
group[
1][10]=new Option("襄樊","襄樊");
group[
1][11]=new Option("荆门","荆门");
group[
2][0]=new Option("石家庄","石家庄");
group[
2][1]=new Option("保定","保定");
group[
2][2]=new Option("张家口","张家口");
group[
2][3]=new Option("承德","承德");
group[
2][4]=new Option("唐山","唐山");
group[
2][5]=new Option("廊坊","廊坊");
group[
2][6]=new Option("沧州","沧州");
group[
2][7]=new Option("衡水","衡水");
group[
2][8]=new Option("邢台","邢台");
group[
2][9]=new Option("邯郸","邯郸");
group[
2][10]=new Option("秦皇岛","秦皇岛");
group[
3][0]=new Option("太原","太原");
group[
3][1]=new Option("大同","大同");
group[
3][2]=new Option("阳泉","阳泉");
group[
3][3]=new Option("榆次","榆次");
group[
3][4]=new Option("长治","长治");
group[
3][5]=new Option("晋城","晋城");
group[
3][6]=new Option("临汾","临汾");
group[
3][7]=new Option("离石","离石");
group[
3][8]=new Option("运城","运城");
group[
3][9]=new Option("忻州","忻州");
group[
4][0]=new Option("呼和浩特","呼和浩特");
group[
4][1]=new Option("包头","包头");
group[
4][2]=new Option("乌海","乌海");
group[
4][3]=new Option("集宁","集宁");
group[
4][4]=new Option("通辽","通辽");
group[
4][5]=new Option("赤峰","赤峰");
group[
4][6]=new Option("东胜","东胜");
group[
4][7]=new Option("锡林浩特","锡林浩特");
group[
4][8]=new Option("海拉尔","海拉尔");
group[
5][0]=new Option("沈阳","沈阳");
group[
5][1]=new Option("大连","大连");
group[
5][2]=new Option("瓦房店","瓦房店");
group[
5][3]=new Option("鞍山","鞍山");
group[
5][4]=new Option("抚顺","抚顺");
group[
5][5]=new Option("本溪","本溪");
group[
5][6]=new Option("丹东","丹东");
group[
5][7]=new Option("锦州","锦州");
group[
5][8]=new Option("营口","营口");
group[
5][9]=new Option("阜新","阜新");
group[
5][10]=new Option("辽阳","辽阳");
group[
5][11]=new Option("铁岭","铁岭");
group[
6][0]=new Option("长春","长春");
group[
6][1]=new Option("吉林","吉林");
group[
6][2]=new Option("延吉","延吉");
group[
6][3]=new Option("四平","四平");
group[
6][4]=new Option("通化","通化");
group[
6][5]=new Option("白城","白城");
group[
6][6]=new Option("辽源","辽源");
group[
6][7]=new Option("前郭","前郭");
group[
6][8]=new Option("浑江","浑江");
group[
6][9]=new Option("梅河口","梅河口");
group[
7][0]=new Option("哈尔滨","哈尔滨");
group[
7][1]=new Option("齐齐哈尔","齐齐哈尔");
group[
7][2]=new Option("牡丹江","牡丹江");
group[
7][3]=new Option("佳木斯","佳木斯");
group[
7][4]=new Option("绥化","绥化");
group[
7][5]=new Option("黑河","黑河");
group[
7][6]=new Option("加格达其","加格达其");
group[
7][7]=new Option("伊春","伊春");
group[
7][8]=new Option("大庆","大庆");
group[
7][9]=new Option("阿城","阿城");
group[
8][0]=new Option("南京","南京");
group[
8][1]=new Option("镇江","镇江");
group[
8][2]=new Option("南通","南通");
group[
8][3]=new Option("苏州","苏州");
group[
8][4]=new Option("扬州","扬州");
group[
8][5]=new Option("盐城","盐城");
group[
8][6]=new Option("徐州","徐州");
group[
8][7]=new Option("淮阴","淮阴");
group[
8][8]=new Option("连云港","连云港");
group[
8][9]=new Option("常州","常州");
group[
8][10]=new Option("无锡","无锡");
group[
8][11]=new Option("常熟","常熟");
group[
8][12]=new Option("张家港","张家港");
group[
9][0]=new Option("杭州","杭州");
group[
9][1]=new Option("湖州","湖州");
group[
9][2]=new Option("嘉兴","嘉兴");
group[
9][3]=new Option("宁波","宁波");
group[
9][4]=new Option("绍兴","绍兴");
group[
9][5]=new Option("临海","临海");
group[
9][6]=new Option("温州","温州");
group[
9][7]=new Option("丽水","丽水");
group[
9][8]=new Option("金华","金华");
group[
9][9]=new Option("衢州","衢州");
group[
10][0]=new Option("合肥","合肥");
group[
10][1]=new Option("蚌埠","蚌埠");
group[
10][2]=new Option("芜湖","芜湖");
group[
10][3]=new Option("马鞍山","马鞍山");
group[
10][4]=new Option("安庆","安庆");
group[
10][5]=new Option("宿县","宿县");
group[
10][6]=new Option("阜阳","阜阳");
group[
10][7]=new Option("黄山","黄山");
group[
10][8]=new Option("滁州","滁州");
group[
10][9]=new Option("淮北","淮北");
group[
10][10]=new Option("铜陵","铜陵");
group[
10][11]=new Option("宣城","宣城");
group[
10][12]=new Option("六安","六安");
group[
10][13]=new Option("巢湖","巢湖");
group[
11][0]=new Option("福州","福州");
group[
11][1]=new Option("厦门","厦门");
group[
11][2]=new Option("宁德","宁德");
group[
11][3]=new Option("莆田","莆田");
group[
11][4]=new Option("泉州","泉州");
group[
11][5]=new Option("漳州","漳州");
group[
11][6]=new Option("龙岩","龙岩");
group[
11][7]=new Option("三明","三明");
group[
11][8]=new Option("南平","南平");
group[
12][0]=new Option("南昌","南昌");
group[
12][1]=new Option("九江","九江");
group[
12][2]=new Option("上饶","上饶");
group[
12][3]=new Option("陵川","陵川");
group[
12][4]=new Option("宜春","宜春");
group[
12][5]=new Option("吉安","吉安");
group[
12][6]=new Option("赣州","赣州");
group[
12][7]=new Option("景德镇","景德镇");
group[
12][8]=new Option("萍乡","萍乡");
group[
12][9]=new Option("分宜","分宜");
group[
13][0]=new Option("济南","济南");
group[
13][1]=new Option("青岛","青岛");
group[
13][2]=new Option("淄博","淄博");
group[
13][3]=new Option("德州","德州");
group[
13][4]=new Option("烟台","烟台");
group[
13][5]=new Option("潍坊","潍坊");
group[
13][6]=new Option("济宁","济宁");
group[
13][7]=new Option("泰安","泰安");
group[
13][8]=new Option("荷泽","荷泽");
group[
13][9]=new Option("威海","威海");
group[
13][10]=new Option("日照","日照");
group[
13][11]=new Option("临沂","临沂");
group[
13][12]=new Option("聊城","聊城");
group[
14][0]=new Option("郑州","郑州");
group[
14][1]=new Option("安阳","安阳");
group[
14][2]=new Option("新乡","新乡");
group[
14][3]=new Option("许昌","许昌");
group[
14][4]=new Option("平顶山","平顶山");
group[
14][5]=new Option("信阳","信阳");
group[
14][6]=new Option("南阳","南阳");
group[
14][7]=new Option("开封","开封");
group[
14][8]=new Option("洛阳","洛阳");
group[
14][9]=new Option("商丘","商丘");
group[
14][10]=new Option("焦作","焦作");
group[
14][11]=new Option("鹤壁","鹤壁");
group[
14][12]=new Option("濮阳","濮阳");
group[
14][13]=new Option("周口","周口");
group[
14][14]=new Option("漯河","漯河");
group[
14][15]=new Option("驻马店","驻马店");
group[
14][16]=new Option("三门峡","三门峡");
group[
15][0]=new Option("海口","海口");
group[
15][1]=new Option("三亚","三亚");
group[
15][2]=new Option("儋县","儋县");
group[
16][0]=new Option("河源","河源");
group[
16][1]=new Option("中山","中山");
group[
16][2]=new Option("顺德","顺德");
group[
16][3]=new Option("东莞","东莞");
group[
16][4]=new Option("江门","江门");
group[
16][5]=new Option("湛江","湛江");
group[
16][6]=new Option("肇庆","肇庆");
group[
16][7]=new Option("佛山","佛山");
group[
16][8]=new Option("珠海","珠海");
group[
16][9]=new Option("深圳","深圳");
group[
16][10]=new Option("汕头","汕头");
group[
16][11]=new Option("梅州","梅州");
group[
16][12]=new Option("广州","广州");
group[
16][13]=new Option("韶关","韶关");
group[
16][14]=new Option("惠州","惠州");
group[
16][15]=new Option("英德","英德");
group[
16][16]=new Option("潮州","潮州");
group[
16][17]=new Option("惠来","惠来");
group[
16][18]=new Option("茂名","茂名");
group[
17][0]=new Option("南宁","南宁");
group[
17][1]=new Option("柳州","柳州");
group[
17][2]=new Option("桂林","桂林");
group[
17][3]=new Option("梧州","梧州");
group[
17][4]=new Option("玉林","玉林");
group[
17][5]=new Option("钦州","钦州");
group[
17][6]=new Option("河池","河池");
group[
17][7]=new Option("北海","北海");
group[
17][8]=new Option("防城","防城");
group[
18][0]=new Option("长沙","长沙");
group[
18][1]=new Option("湘潭","湘潭");
group[
18][2]=new Option("株州","株州");
group[
18][3]=new Option("衡阳","衡阳");
group[
18][4]=new Option("郴州","郴州");
group[
18][5]=new Option("常德","常德");
group[
18][6]=new Option("益阳","益阳");
group[
18][7]=new Option("娄底","娄底");
group[
18][8]=new Option("邵阳","邵阳");
group[
18][9]=new Option("岳阳","岳阳");
group[
18][10]=new Option("怀化","怀化");
group[
19][0]=new Option("成都","成都");
group[
19][1]=new Option("攀枝花","攀枝花");
group[
19][2]=new Option("自贡","自贡");
group[
19][3]=new Option("永川","永川");
group[
19][4]=new Option("温江","温江");
group[
19][5]=new Option("绵阳","绵阳");
group[
19][6]=new Option("南充","南充");
group[
19][7]=new Option("达县","达县");
group[
19][8]=new Option("万县市","万县市");
group[
19][9]=new Option("涪陵","涪陵");
group[
19][10]=new Option("沪州","沪州");
group[
19][11]=new Option("宜宾","宜宾");
group[
19][12]=new Option("内江","内江");
group[
19][13]=new Option("乐山","乐山");
group[
19][14]=new Option("西昌","西昌");
group[
19][15]=new Option("雅安","雅安");
group[
19][16]=new Option("马尔康","马尔康");
group[
19][17]=new Option("德阳","德阳");
group[
19][18]=new Option("广元","广元");
group[
20][0]=new Option("贵阳","贵阳");
group[
20][1]=new Option("遵义","遵义");
group[
20][2]=new Option("安顺","安顺");
group[
20][3]=new Option("都匀","都匀");
group[
20][4]=new Option("凯里","凯里");
group[
20][5]=new Option("铜仁","铜仁");
group[
20][6]=new Option("毕节","毕节");
group[
20][7]=new Option("六盘水","六盘水");
group[
20][8]=new Option("兴义","兴义");
group[
21][0]=new Option("昆明","昆明");
group[
21][1]=new Option("大理","大理");
group[
21][2]=new Option("个旧","个旧");
group[
21][3]=new Option("曲靖","曲靖");
group[
21][4]=new Option("保山","保山");
group[
21][5]=new Option("文山","文山");
group[
21][6]=new Option("玉溪","玉溪");
group[
21][7]=new Option("楚雄","楚雄");
group[
21][8]=new Option("思茅","思茅");
group[
21][9]=new Option("昭通","昭通");
group[
22][0]=new Option("拉萨","拉萨");
group[
23][0]=new Option("西安","西安");
group[
23][1]=new Option("延安","延安");
group[
23][2]=new Option("榆林","榆林");
group[
23][3]=new Option("商州","商州");
group[
23][4]=new Option("安康","安康");
group[
23][5]=new Option("汉中","汉中");
group[
23][6]=new Option("宝鸡","宝鸡");
group[
23][7]=new Option("铜川","铜川");
group[
23][8]=new Option("咸阳","咸阳");
group[
23][9]=new Option("长安","长安");
group[
24][0]=new Option("兰州","兰州");
group[
24][1]=new Option("定西","定西");
group[
24][2]=new Option("平凉","平凉");
group[
24][3]=new Option("西峰","西峰");
group[
24][4]=new Option("武威","武威");
group[
24][5]=new Option("张掖","张掖");
group[
24][6]=new Option("酒泉","酒泉");
group[
24][7]=new Option("天水","天水");
group[
24][8]=new Option("成都","成都");
group[
24][9]=new Option("林夏","林夏");
group[
25][0]=new Option("银川","银川");
group[
25][1]=new Option("石嘴山","石嘴山");
group[
25][2]=new Option("吴忠","吴忠");
group[
25][3]=new Option("固原","固原");
group[
26][0]=new Option("西宁","西宁");
group[
26][1]=new Option("平安","平安");
group[
26][2]=new Option("同仁","同仁");
group[
26][3]=new Option("共和","共和");
group[
26][4]=new Option("德令哈","德令哈");
group[
26][5]=new Option("门源","门源");
group[
26][6]=new Option("格尔木","格尔木");
group[
27][0]=new Option("乌鲁木齐","乌鲁木齐");
group[
27][1]=new Option("奎屯","奎屯");
group[
27][2]=new Option("石河子","石河子");
group[
27][3]=new Option("昌吉","昌吉");
group[
27][4]=new Option("吐鲁番","吐鲁番");
group[
27][5]=new Option("库尔勒","库尔勒");
group[
27][6]=new Option("阿克苏","阿克苏");
group[
27][7]=new Option("喀什","喀什");
group[
27][8]=new Option("伊犁","伊犁");
group[
27][9]=new Option("克拉玛依","克拉玛依");
 
function goGo(x){
var tempff=document.getElementById("city");     
    
for (m=tempff.options.length-1;m>0;m--
       tempff.options[m]
=null
   
for (i=0;i<group[x].length;i++){ 
       tempff.options[i]
=new Option(group[x][i].text,group[x][i].value); 
    } 
    tempff.options[
0].selected=true

 
//--> 
</script>
</body>
</html>


posted on 2008-07-04 17:30 月芽儿 阅读(2732) 评论(0)  编辑  收藏 所属分类: 建站技巧杂侃


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

相册

搜索

最新评论

阅读排行榜

评论排行榜