[求助]用JAVASCRIPT实现省份城市的选择
选择省出现相应的城市,有谁能帮帮我
[CODE]<script language="JavaScript">
function bb(num){
city = new Array();
city[1]= new Array("唐山市","1","1");
city[2]= new Array("石家庄","2","1");
city[3]= new Array("营口市","3","2");
city[4]= new Array("沈阳市","4","2");
//把数组的值用数据库读出
document.form1.s1.length = 0;
document.form1.s1.options[0]= new Option("请选择市","0");
j=1;
for(i=1;i<=4;i++)
{ if(city[i][2]==num)
{document.form1.s1.options[document.form1.s1.length]= new Option(city[i][0],city[i][1]);}
j++}
}
function cc(num){
city = new Array();
city[1]= new Array("唐山路北区","1","1");
city[2]= new Array("唐山古冶区","2","1");
city[3]= new Array("石家庄正定","3","2");
city[4]= new Array("石家庄新集","4","2");
city[5]= new Array("营口站前区","5","3");
city[6]= new Array("营口西市区","6","3");
city[7]= new Array("沈阳市区","7","4");
city[8]= new Array("沈阳三好街","8","4");
//把数组的值用数据库读出
document.form1.s2.length = 0;
document.form1.s2.options[0]= new Option("请选择县","0");
j=1;
for(i=1;i<=8;i++)
{ if(city[i][2]==num)
{document.form1.s2.options[document.form1.s2.length]= new Option(city[i][0],city[i][1]);}
j++}
}
</script>
<body>
<form name="form1" method="post" action="">
<!--form1.ss的值用数据库读出-->
<select name="ss" onChange="bb(document.form1.ss.options[document.form1.ss.selectedIndex].value)">
<option value="0">请选择省</option>
<option value="1">河北省</option>
<option value="2">辽宁省</option>
</select>
<select name="s1" onChange="cc(this.value)">
</select>
<select name="s2" id="s2">
</select>
</form>
</body>[/CODE]