标题:[求助]用JAVASCRIPT实现省份城市的选择
只看楼主
xiuyuan123
Rank: 2
等 级:新手上路
威 望:3
帖 子:140
专家分:0
注 册:2006-4-25
 问题点数:0 回复次数:5 
[求助]用JAVASCRIPT实现省份城市的选择
选择省出现相应的城市,有谁能帮帮我
搜索更多相关主题的帖子: JAVASCRIPT 省份 选择 
2006-05-25 14:05
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
得分:0 
[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]
2006-05-25 14:59
xiuyuan123
Rank: 2
等 级:新手上路
威 望:3
帖 子:140
专家分:0
注 册:2006-4-25
得分:0 

谢谢啊,可以用


2006-05-26 11:38
ldlxs
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-8-8
得分:0 
谢谢!!!
2006-05-30 12:16
supersoup
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-8-8
得分:0 
不管怎么样.都 要说声谢谢
2006-08-08 18:19
xiao_2008
Rank: 1
等 级:新手上路
帖 子:103
专家分:0
注 册:2006-4-22
得分:0 
xiexie

看动画片
2006-10-15 17:15



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




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

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