省名与城名下拉选择框联动

表单中,第一个列表框有a,b,c三个选项,当用户选中a时,第二个列表框显示a1,a2,a3三个选项,(若用户在第一个列表框中选择b,第二个列表框显示b1,b2,b3,以此类推),当用户在第二个列表框中选择a1,第三个列表框中显示a11,a12,a13。请问如何实现?
---------------------------------------------------------------

给你一个,以此类推

 1<script language="javascript">   
 2<!--   
 3var onecount;   
 4onecount=0;   
 5  
 6subcat = new Array();   
 7subcat[0] = new Array("徐汇区","01","001");   
 8subcat[1] = new Array("嘉定区","01","002");   
 9subcat[2] = new Array("黄浦区","01","003");   
10subcat[3] = new Array("南昌市","02","004");   
11subcat[4] = new Array("九江市","02","005");   
12subcat[5] = new Array("上饶市","02","006");   
13  
14onecount=6;   
15  
16function changelocation(locationid)   
17{   
18document.myform.smalllocation.length = 0;   
19  
20var locationid=locationid;   
21var i;   
22document.myform.smalllocation.options[0] = new Option('====所有地区====','');   
23for (i=0;i < onecount; i++)   
24{   
25if (subcat[i][1] == locationid)   
26{   
27document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);   
28}   
29}   
30  
31}   
32  
33//-->   
34</script>
1<form method="post" name="myform">
2<select name="biglocation" onchange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)">
3<option selected="" value="01">上海</option>
4<option value="02">江西</option>
5</select>
6<select name="smalllocation">
7<option selected="" value="">==所有地区==</option>
8</select>
9</form>

---------------------------------------------------------------

1<script language="JavaScript"></script>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus