下拉框连动的小例子(.htm版)

 1<html>
 2<head>
 3<title>List</title>
 4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 5<script language="javascript">   
 6<!--   
 7var onecount;   
 8onecount=0;   
 9  
10subcat = new Array();   
11subcat[0] = new Array("徐汇区","01","001");   
12subcat[1] = new Array("嘉定区","01","002");   
13subcat[2] = new Array("黄浦区","01","003");   
14subcat[3] = new Array("南昌市","02","004");   
15subcat[4] = new Array("九江市","02","005");   
16subcat[5] = new Array("上饶市","02","006");   
17  
18onecount=6;   
19  
20function changelocation(locationid)   
21{   
22document.myform.smalllocation.length = 0;   
23  
24var locationid=locationid;   
25var i;   
26document.myform.smalllocation.options[0] = new Option('====所有地区====','');   
27for (i=0;i < onecount; i++)   
28{   
29if (subcat[i][1] == locationid)   
30{   
31document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);   
32}   
33}   
34  
35}   
36  
37//-->   
38</script>
39</head>
40<body>
41<form method="post" name="myform">
42<select name="biglocation" onchange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)">
43<option selected="" value="01">上海</option>
44<option value="02">江西</option>
45</select>
46<select name="smalllocation">
47<option selected="" value="">==所有地区==</option>
48</select>
49</form>
50<script language="javascript">   
51<!--   
52changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value);   
53//-->   
54</script>
55</body>
56</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus