级联菜单:(1.js文件)
 1 function Dsy() 
 2 
 3     this.Items = {};
 4  }
 5 Dsy.prototype.add = function(id,iArray) { this.Items[id] = iArray; } 
 6 Dsy.prototype.Exists = function(id) { if(typeof(this.Items[id]) == "undefined"return falsereturn true; };
 7 function change(v){
 8     var str="0";
 9     for(i=0;i<v;i++)
10     { 
11         str+=("_"+(document.getElementById(s[i]).selectedIndex-1));
12     };
13     var ss=document.getElementById(s[v]);
14     with(ss){
15         length = 0;
16         options[0]=new Option(opt0[v],opt0[v]);
17         if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
18         {
19             if(dsy.Exists(str)){
20                 ar = dsy.Items[str];
21                 for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
22                 if(v)options[1].selected = true;
23             }
24         }
25         if(++v<s.length){change(v);}
26     }
27 }
28 var dsy = new Dsy();
29 dsy.add("0",["安徽省","北京市","福建省","甘肃省","广东省","广西壮族自治区","贵州省","海南省","河北省","河南省","黑龙江省","湖北省","湖南省","吉林省","江苏省","江西省","解放军","辽宁省","内蒙古自治区","宁夏回族自治区","青海省","山东省","山西省","陕西省","上海市","四川省","台湾省","天津市","西藏自治区","新疆维吾尔自治区","云南省","浙江省"]);  dsy.add("0_0_0",["枞阳县","大观区","怀宁县","郊区","潜山县","市辖区","宿松县","太湖县","桐城县","望江县","迎江区","岳西县"]); dsy.add("0_0_1",["东市区","固镇县","怀远县","郊区","市辖区","五河县","西市区","中市区"]); dsy.add("0_0_2",["巢湖市","含山县","和县","庐江县","无为县"]); ; dsy.add("0_5_12",["北流县","博白县","贵港市","桂平县","陆川县","平南县","容县","玉林市"]); dsy.add("0_5",["百色地区","北海市","桂林地区","桂林市","河池地区","柳州地区","柳州市","南宁地区","南宁市","钦州地区","梧州地区","梧州市","玉林地区"]); dsy.add("0_6_0",["安顺市","关岭布依族苗族自治县","开阳县","平坝县","普定县","清镇市","息烽县","修文县","镇宁布依族苗族自治县","紫云苗族布依族自治县"]); dsy.add("0_6_1",["毕节县","大方县","赫章县","金沙县","纳雍县","黔西县","威宁彝族回族苗族自治县","织金县"]); dsy.add("0_6_2",["白云区","花溪区","南明区","市辖区","乌当区","云岩区"]); dsy.add("0_6_3",["六枝特区","盘县特区","水城县","钟山区"]); dsy.add("0_6_4",["岑巩县","从江县","丹寨县","黄平县","剑河县","锦屏县","凯里市","雷山县","黎平县","麻江县","榕江县","三穗县","施秉县","台江县","天柱县","镇远县"]); dsy.add("0_6_5",["长顺县","都匀市","独山县","福泉县","贵定县","惠水县","荔波县","龙里县","罗甸县","平塘县","三都水族自治县","瓮安县"]); dsy.add("0_6_6",["安龙县","册亨县","普安县","晴隆县","望谟县","兴仁县","兴义市","贞丰县"]); dsy.add("0_6_7",["德江县","江口县","石阡县","思南县","松桃苗族自治县","铜仁市","万山特区","沿河土家族自治县","印江土家族苗族自治县","玉屏侗族自治县"]); dsy.add("0_6_8",["赤水市","道真仡佬族苗族自治县","凤冈县","湄潭县","仁怀县","绥阳县","桐梓县","务川仡佬族苗族自治县","习水县","余庆县","正安县","遵义市","遵义县"]); dsy.add("0_6",["安顺地区","毕节地区","贵阳市","六盘水市","黔东南苗族侗族自治州","黔南布依族苗族自治州","黔西南布依族苗族自治州","铜仁地区","遵义地区"]); dsy.add("0_7_7",["市辖区","新华区","秀英区","振东区"]); dsy.add("0_7_15",["市辖区"]); dsy.add("0_7",["白沙黎族自治县","保亭黎族苗族自治县","昌江黎族自治县","澄迈县","儋县","定安县","东方黎族自治县","海口市","乐东黎族自治县","临高县","陵水黎族自治县","南沙群岛","琼海市","琼山县","琼中黎族苗族自治县","三亚市","通什市","屯昌县","万宁县","文昌县","西沙群岛","中沙群岛的岛礁及其海域"]); dsy.add("0_8_0",["安国市","安新县","博野县","定兴县","定州市","阜平县","高阳县","涞水县","涞源县","蠡县","曲阳县","容城县","唐县","完县","望都县","新城县","雄县","徐水县","易县","涿州市"]); dsy.add("0_8_1",["北市区","满城县","南市区","清苑县","市辖区","新市区"]); dsy.add("0_8_2",["泊头市","东光县","海兴县","河间市","黄骅市","孟村回族自治县","南皮县","任丘市","肃宁县","吴桥县","献县","盐山县"]); dsy.add("0_8_3",["沧县","郊区","青县","市辖区","新华区","运河区"]); dsy.add("0_8_4",["丰宁满族自治县","宽城满族自治县","隆化县","滦平县","平泉县","围场满族蒙古族自治县","兴隆县"]); dsy.add("0_8_5",["承德县","市辖区","双滦区","双桥区","鹰手营子矿区"]); dsy.add("0_8_6",["成安县","磁县","大名县","肥乡县","馆陶县","广平县","鸡泽县","临漳县","丘县","曲周县","涉县","魏县","永年县"]); dsy.add("0_8_7",["丛台区","峰峰矿区","复兴区","邯郸县","邯山区","市辖区","武安市"]); dsy.add("0_8_8",["安平县","阜城县","故城县","衡水市","冀县","景县","饶阳县","深县","武强县","武邑县","枣强县"]); dsy.add("0_8_9",["安次区","霸州市","大厂回族自治县","大城县","固安县","三河县","市辖区","文安县","香河县","永清县"]); 

HTML:
 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 2 <html>
 3 <head>
 4 <script language="JavaScript" src="area.js"></script>
 5 <SCRIPT LANGUAGE = JavaScript>
 6 <!--
 7 //** Power by Fason(2004-3-11)
 8 //** Email:fason_pfx@hotmail.com
 9 
10 var s=["s1","s2","s3"];
11 var opt0 = ["省份","地级市","市、县级市、县"];
12 function setup()
13 {
14     for(i=0;i<s.length-1;i++)
15     {
16         document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
17         alert(i);
18     }
19     change(0);
20 }
21 //-->
22 </SCRIPT>
23 <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
24 <title>添加网站-步骤2</title>
25 </head>
26 <body  onload="setup()">
27 所在地址:
28 <select name="s1" id="s1"></select>
29 <select name="s2" id="s2"></select>
30 <select name="s3" id="s3"></select>
31 </body>
32 </html>

posted on 2007-02-07 09:58 -274°C 阅读(1368) 评论(2)  编辑  收藏 所属分类: web前端


FeedBack:
# re: 省市地区三级菜单
2007-02-07 15:34 | nspace----from qq java group
是不是有bug?  回复  更多评论
  
# re: 省市地区三级菜单
2007-02-07 15:42 | JAVA-HE
什么bug?地理数据我灭有写全,需要完整的程序,可以加我群:30132694
  回复  更多评论
  

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


网站导航:
 

常用链接

留言簿(21)

随笔分类(265)

随笔档案(242)

相册

JAVA网站

关注的Blog

搜索

  •  

积分与排名

  • 积分 - 871703
  • 排名 - 37

最新评论