| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1191 人关注过本帖
标题:求助:三级联动菜单,请高手出招,将第三级改成文本框,谢谢
只看楼主 加入收藏
luxc
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-9
收藏
得分:0 

<html>
<head>
<title>改变option的内容</title>
</head>
<body>
<form name="ADDUser" method="POST" action="" onSubmit="return Checkreg();">
<table border="1">
<tr>
<td>
<select name="t1" onchange="gett2(selectedIndex)">
<option value="省份" selected>选择省份</option>
<% connstr="DBQ="+server.mappath("ybqh.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=Server.CreateObject("ADODB.connection")
conn.open connstr%>
<%
set rs=conn.execute("select distinct sm from ybqh")
do while not rs.eof
%>
<option value="<%=rs("sm")%>"><%=rs("sm")%></option>
<%
rs.moveNext

Loop
%>
</select>
</td>
<td id="ct">
<select name="t2" onchange="gettxt(selectedIndex)">
<option value="请选择">请选择</option>
</select>
</td>
<td width="217" id="ct"><textarea name="txt" id="txt"></textarea></td>
</tr>
</table> </form>
<script language="JavaScript">
function gett2(i) {
ADDUser.t2.options.length=0; //删除所有的选项
var s;
s=ADDUser.t1.options[i].text;

<%
'打开库
connstr="DBQ="+server.mappath("ybqh.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=Server.CreateObject("ADODB.connection")
conn.open connstr

set rs2=conn.execute("select * from ybqh ")
'设值处理if条件
tid=0
firstrow=1
do while not rs2.eof
if tid<>rs2("sm") then
tid=rs2("sm")
if firstrow=1 then
response.write("if(s=='" &tid& "') {")

set rs3=conn.execute("select distinct qh from ybqh where sm='" &rs2("sm")& "'" )
do while not rs3.eof
response.write("var op=new Option('" &rs3("qh")& "','" &rs3("qh")& "',false,false);")
response.write("ADDUser.t2.options[ADDUser.t2.options.length]=op;")
rs3.movenext
loop
rs3.close
set rs3=nothing
firstrow=0
else
response.write(" } if(s=='" &tid& "') {")

set rs3=conn.execute("select distinct qh from ybqh where sm='" &rs2("sm")& "'")
do while not rs3.eof
response.write("var op=new Option('" &rs3("qh")& "','" &rs3("qh")& "',false,false);")
response.write("ADDUser.t2.options[ADDUser.t2.options.length]=op;")
rs3.movenext
loop
rs3.close
set rs3=nothing
end if
end if


rs2.movenext
loop
response.write("}")

%>

}
</script>
<script language="JavaScript">
function gettxt(i) {
ADDUser.txt.value.length=0; //删除所有的选项
var s1;
s1=ADDUser.t2.options[i].text;

<%
'打开库


set rs4=conn.execute("select * from ybqh ")
'设值处理if条件
tid1=0
firstrow=1
do while not rs4.eof
if tid1<>rs4("qh") then
tid1=rs4("qh")
if firstrow=1 then
response.write("if(s1=='" &tid1& "') {")
firstrow=0
else
response.write(" } if(s1=='" &tid1& "') {")

end if
end if
response.write("var op=('" &rs4("dq")& "');")
response.write("ADDUser.txt.value=op;")

rs4.movenext
loop
response.write("}")
rs4.close
set rs2=nothing
conn.close
set conn=nothing
%>

}
</script>
</body>
</html>

2007-04-12 18:11
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
<html>
<head>
<title>改变option的内容</title>
</head>
<body>
<form name="ADDUser" method="POST" action="" onSubmit="return Checkreg();">
<table border="1">
<tr>
<td>
<select name="t1" onchange="gett2(selectedIndex)">
<option value="省份" selected>选择省份</option>

<option value="河北">河北</option>

</select>
</td>
<td id="ct">
<select name="t2" onchange="gettxt(selectedIndex)">
<option value="请选择">请选择</option>
</select>
</td>
<td width="217" id="ct"><select name="txt" >
<option value="请选择" selected>请选择</option>
</select> </td>
</tr>
</td>
<td width="217" id="ct">
<input type="text" name="inpTxt" >
</td>
</tr>
</table> </form>
<script language="JavaScript">
function gett2(i)
{
ADDUser.t2.options.length=0; //删除所有的选项
var s;
s=ADDUser.t1.options[i].text;
if(s=='河北')
{
var op=new Option('0310','0310',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0311','0311',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0312','0312',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0315','0315',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0316','0316',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0317','0317',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0318','0318',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0319','0319',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
var op=new Option('0335','0335',false,false);
ADDUser.t2.options[ADDUser.t2.options.length]=op;
}

}
</script>
<script language="JavaScript">
function gettxt(i)
{
ADDUser.txt.options.length=0; //删除所有的选项
var s1;
s1=ADDUser.t2.options[i].text;
if(s1=='0311')
{
var op=new Option('石家庄','石家庄',false,false);
ADDUser.inpTxt.value+=op.text+"|";
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('获鹿','获鹿',false,false);
ADDUser.inpTxt.value+=op.text+"|";
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('正定','正定',false,false);
ADDUser.inpTxt.value+=op.text+"|";
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('栾城','栾城',false,false);
ADDUser.inpTxt.value+=op.text+"|";
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('井陉','井陉',false,false);
ADDUser.inpTxt.value+=op.text+"|";
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('元氏','元氏',false,false);
ADDUser.inpTxt.value+=op.text+"|";
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('新乐','新乐',false,false);
ADDUser.inpTxt.value+=op.text+"|";
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0312')
{
var op=new Option('清苑','清苑',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('涞水','涞水',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('易县','易县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('涞源','涞源',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('唐县','唐县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('定兴','定兴',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('涿州','涿州',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('高碑店','高碑店',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('博野','博野',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('安国','安国',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0315')
{
var op=new Option('唐山','唐山',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('玉田','玉田',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('滦县','滦县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('遵化','遵化',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('滦南','滦南',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('唐海','唐海',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('丰南','丰南',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0316')
{
var op=new Option('霸州','霸州',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('永清','永清',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('大城','大城',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('文安','文安',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('固安','固安',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('香河','香河',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('大厂','大厂',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('三河','三河',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0317')
{
var op=new Option('沧州','沧州',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('黄骅','黄骅',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('海兴','海兴',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('盐山','盐山',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('孟村','孟村',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('青县','青县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('南皮','南皮',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('东光','东光',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('吴桥','吴桥',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('泊头','泊头',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('河间','河间',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('肃宁','肃宁',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('任丘','任丘',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('献县','献县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0318')
{
var op=new Option('衡水','衡水',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('铙阳','铙阳',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0319')
{
var op=new Option('新河','新河',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('南宫','南宫',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('清河','清河',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('威县','威县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0310')
{
var op=new Option('涉县','涉县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('成安','成安',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('永年','永年',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('鸡泽','鸡泽',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('曲周','曲周',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('丘县','丘县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('馆陶','馆陶',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('大名','大名',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('魏县','魏县',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('广平','广平',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('肥乡','肥乡',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}
if(s1=='0335')
{
var op=new Option('秦皇岛','秦皇岛',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('昌黎','昌黎',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('卢龙','卢龙',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('抚宁','抚宁',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
var op=new Option('青龙','青龙',false,false);
ADDUser.txt.options[ADDUser.txt.options.length]=op;
}

}
</script>
</body>
</html>
只改了一项其他楼主以此类推。
2007-04-12 23:07
luxc
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-9
收藏
得分:0 

搞定,谢谢老大帮忙,现将代码放上,供大家参考

<html>
<head>
<title>改变option的内容</title>
</head>
<body>
<form name="ADDUser" method="POST" action="" onSubmit="return Checkreg();">
<table border="1">
<tr>
<td>
<select name="t1" onchange="gett2(selectedIndex)">
<option value="省份" selected>选择省份</option>
<% connstr="DBQ="+server.mappath("ybqh.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=Server.CreateObject("ADODB.connection")
conn.open connstr%>
<%
set rs=conn.execute("select distinct sm from ybqh")
do while not rs.eof
%>
<option value="<%=rs("sm")%>"><%=rs("sm")%></option>
<%
rs.moveNext

Loop
%>
</select>
</td>
<td id="ct">
<select name="t2" onchange="gettxt(selectedIndex)">
<option value="请选择">请选择</option>
</select>
</td>
<td width="217" id="ct"><textarea name="txt" id="txt"></textarea></td>
</tr>
</table> </form>
<script language="JavaScript">
function gett2(i) {
ADDUser.t2.options.length=0; //删除所有的选项
var s;
s=ADDUser.t1.options[i].text;

<%
'打开库
connstr="DBQ="+server.mappath("ybqh.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=Server.CreateObject("ADODB.connection")
conn.open connstr

set rs2=conn.execute("select * from ybqh ")
'设值处理if条件
tid=0
firstrow=1
do while not rs2.eof
if tid<>rs2("sm") then
tid=rs2("sm")
if firstrow=1 then
response.write("if(s=='" &tid& "') {")

set rs3=conn.execute("select distinct qh from ybqh where sm='" &rs2("sm")& "'" )
do while not rs3.eof
response.write("var op=new Option('" &rs3("qh")& "','" &rs3("qh")& "',false,false);")
response.write("ADDUser.t2.options[ADDUser.t2.options.length]=op;")
rs3.movenext
loop
rs3.close
set rs3=nothing
firstrow=0
else
response.write(" } if(s=='" &tid& "') {")

set rs3=conn.execute("select distinct qh from ybqh where sm='" &rs2("sm")& "'")
do while not rs3.eof
response.write("var op=new Option('" &rs3("qh")& "','" &rs3("qh")& "',false,false);")
response.write("ADDUser.t2.options[ADDUser.t2.options.length]=op;")
rs3.movenext
loop
rs3.close
set rs3=nothing
end if
end if


rs2.movenext
loop
response.write("}")

%>

}
</script>
<script language="JavaScript">
function gettxt(i) {
ADDUser.txt.value.length=0; //删除所有的选项
var s1;
s1=ADDUser.t2.options[i].text;

<%
'打开库


set rs4=conn.execute("select * from ybqh ")
'设值处理if条件
tid1=0
firstrow=1
do while not rs4.eof
if tid1<>rs4("qh") then
tid1=rs4("qh")
if firstrow=1 then
response.write("if(s1=='" &tid1& "') {")
firstrow=0
else
response.write(" } if(s1=='" &tid1& "') {")

end if
end if
response.write("var op=new Option('" &rs4("dq")& "','" &rs4("dq")& "',false,false);")
response.write("ADDUser.txt.value+=op.text+'、';")

rs4.movenext

loop
response.write("}")
rs4.close
set rs2=nothing
conn.close
set conn=nothing
%>

}
</script>
</body>
</html>

2007-04-13 15:35
快速回复:求助:三级联动菜单,请高手出招,将第三级改成文本框,谢谢
数据加载中...
 
   



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

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