标签:
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>菜单二级联动效果</title>
6 </head>
7 <body>
8 <script language="JavaScript" type="text/javascript">
9 /*var city=[
10 ["北京","天津","上海","重庆"],
11 ["南京","苏州","南通","常州"],
12 ["福州","福安","龙岩","南平"],
13 ["广州","潮阳","潮州","澄海"],
14 ["兰州","白银","定西","敦煌"]
15 ];*/
16 //或者
17 var city = new Array;
18 city[0] = Array("北京","天津","上海","重庆");
19 city[1] = Array("南京","苏州","南通","常州");
20 city[2] = Array("福州","福安","龙岩","南平");
21 city[3] = Array("广州","潮阳","潮州","澄海");
22 city[4] = Array("兰州","白银","定西","敦煌");
23 function getCity(){
24 var sltProvince=document.getElementById("province");
25 var sltCity=document.getElementById("city");
26 var provinceCity=city[sltProvince.selectedIndex-1];
27 //sltCity.length=1;
28 for(var i=0;i<provinceCity.length;i++){
29 sltCity[i+1]=new Option(provinceCity[i]);
30 }
31 }
32
33 </script>
34 <form action="#" name="theForm">
35 <select name="province" id="province" onchange="getCity()">
36 <option value="0">请选择所在省份</option>
37 <option value="直辖市">直辖市</option>
38 <option value="江苏省">江苏省</option>
39 <option value="福建省">福建省</option>
40 <option value="广东省">广东省</option>
41 <option value="甘肃省">甘肃省</option>
42 </select>
43 <select id="city" name="city">
44 <option value="0">请选择所在城市</option>
45 </select>
46 </form>
47 </body>
48 </html>
标签:
原文地址:http://www.cnblogs.com/fengxiaopiaoer/p/5654235.html