标题:[求助]求做一个三级下拉列表框
只看楼主
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
不用的时候不说回复,用的时候选求助。
2005-08-08 21:02
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
建议收录到居顶问题贴中

面朝大海,春暖花开!
2005-08-09 11:17
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5807
专家分:108
注 册:2005-4-7
得分:0 
应该已经收录了吧

2005-08-09 11:22
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
顶一下..

面朝大海,春暖花开!
2005-08-18 09:06
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
得分:0 
网上的我也看不好
我写了一个静态的 相应改成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编辑过]


2005-08-18 13:35
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5807
专家分:108
注 册:2005-4-7
得分:0 
不错不错
简练

2005-08-18 14:26
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
强,,顶..

面朝大海,春暖花开!
2005-08-18 14:27
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5807
专家分:108
注 册:2005-4-7
得分:0 
有一个小问题


就是当第一级改变以后应该把第二,三级归位(好象这个第三级没有归位)

[此贴子已经被作者于2005-8-18 14:31:27编辑过]



2005-08-18 14:30
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
就是,选了一第级时,第三级好像没有归位或者出现相应的情况,,

面朝大海,春暖花开!
2005-08-18 14:34
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
得分:0 
顶,虽然我还没用过

中国人的财富网:http://www..cn/
2005-08-18 14:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-24622-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.133061 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved