网上的我也看不好
我写了一个静态的 相应改成ASP读数据库的就行了
先测试一下
[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.s2.length = 0;
document.form1.s2.options[0]= new Option("还没有县","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(document.form1.s1.options[document.form1.s1.selectedIndex].value)">
</select>
<select name="s2" id="s2">
</select>
</form>
</body>
[/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.s2.length = 0;
document.form1.s2.options[0]= new Option("还没有县","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(document.form1.s1.options[document.form1.s1.selectedIndex].value)">
</select>
<select name="s2" id="s2">
</select>
</form>
</body>
[此贴子已经被作者于2005-8-18 14:54:23编辑过]