asp三级联动

<%Db="../data/d@#$%&ata.asp"setconn=server.createObject("adodb.connection")connstr="d... <%
Db="../data/d@#$%&ata.asp"
set conn= server.createObject("adodb.connection")
connstr="dbq="+server.mappath(Db)+";defaultdir=;driver={microsoft access driver (*.mdb)};"
conn.open connstr
%>
<%
Set rs = server.createobject("adodb.recordset")
SQL = "select * from first where type='first'"
rs.Open SQL, conn, 1, 1
%>
<SELECT name="sheng" ID="sheng">
<% if not(rs.eof and rs.bof) then
do while not rs.eof %>
<option><%= rs("name") %>
<%
firsttype=rs("name")
rs.movenext
loop
end if
%>
</select>
<select name="BigClassName" size="1">
<%
Set rs1 = server.createobject("adodb.recordset")
SQL1 = "select * from NewBigClass where Bigtype='"&firsttype&"'"
rs1.Open SQL1, conn, 1, 1
%>
<% if not(rs.eof and rs.bof) then
do while not rs.eof %>
<option value="<%= rs1("BigClassName") %>"><%= rs1("BigClassName") %>
</select>
<%
secondttype=rs1("BigClassName")
rs1.movenext
loop
end if
%>

<%
Set rs2 = server.createobject("adodb.recordset")
SQL2 = "select * from SmallClass where BigClassName='"&secondttype&"'"
rs2.Open SQL2, conn, 1, 1
%>
<select name="SmallClassName" onChange="changelocation(document.addNEWS.SmallClassName.options[document.addNEWS.SmallClassName.selectedIndex].value)" size="1">
<% if not(rs.eof and rs.bof) then
do while not rs.eof %>
<option><%= rs2("SmallClassName") %>
<%
rs2.movenext
loop
end if
rs.close
rs1.close
rs2.close
%>
</select>

哪个 朋友帮我加点JS代码把值帮我传到相应的位置,谢谢啦.
展开
 我来答
egoplay
2008-09-09 · TA获得超过787个赞
知道小有建树答主
回答量:934
采纳率:0%
帮助的人:413万
展开全部
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.Mappath("db1.mdb")
'=========================================================
'表
'---------------------------------------------------------
'大类:F_Class 字段:Class_ID,Class_Name
'小类:F_nClass 字段:nClass_ID,nClass_Name,ClassID
'细目:F_Item 字段:Item_ID,Item_Name,nClass_ID.Class_ID
'---------------------------------------------------------
'测试Page
'---------------------------------------------------------
'Request.form("FClass")
'Request.form("FnClass")
'Request.form("FItem")
'=========================================================
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<!------------------------------------------------------------------------------------------------------->
<script language="JavaScript">
<%
'二级数据保存到数组
Dim Count2,RsClass2,sqlClass2
set RsClass2=Server.Createobject("adodb.recordset")
sqlClass2="Select * from F_nClass"
RsClass2.Open sqlClass2,conn,1,1
%>
var Subval2 = new Array();
//数组结构:一级根值,二级根值,二级显示值
<%
Count2 = 0
Do while not RsClass2.Eof
%>
Subval2[<%=Count2%>] = new Array('<%=RsClass2("Class_ID")%>','<%=RsClass2("nClass_ID")%>','<%=RsClass2("nClass_Name")%>')
<%
Count2 = Count2 + 1
RsClass2.MoveNext
Loop
RsClass2.Close
%>

<%
'三级数据保存到数组
Dim Count3,RsClass3,sqlClass3
set RsClass3=server.createobject("adodb.recordset")
sqlClass3="Select * from F_Item"
RsClass3.Open sqlClass3,Conn,1,1
%>
var Subval3 = new Array();
//数组结构:二级根值,三级根值,三级显示值s
<%
Count3 = 0
Do while not RsClass3.Eof
%>
Subval3[<%=Count3%>] = new Array('<%=RsClass3("nClass_ID")%>','<%=RsClass3("Item_ID")%>','<%=RsClass3("Item_Name")%>');
<%
Count3 = Count3 + 1
RsClass3.MoveNext
Loop
RsClass3.Close
%>

function Changeselect1(locationid)
{
document.form1.FnClass.length = 0;
document.form1.FnClass.options[0] = new Option('==请选择小类==','');
document.form1.FItem.length = 0;
document.form1.FItem.options[0] = new Option('==请选择细目==','');
for (i=0; i<Subval2.length; i++)
{
if (Subval2[i][0] == locationid)
{document.form1.FnClass.options[document.form1.FnClass.length] = new Option(Subval2[i][2],Subval2[i][1]);}
}
}

function Changeselect2(locationid)
{
document.form1.FItem.length = 0;
document.form1.FItem.options[0] = new Option('==请选择细目==','');
for (i=0; i<Subval3.length; i++)
{
if (Subval3[i][0] == locationid)
{document.form1.FItem.options[document.form1.FItem.length] = new Option(Subval3[i][2],Subval3[i][1]);}
}
}

function RegForm()
{
if (document.form1.FClass.value.length ==0)
{
alert('请选择大类');
document.form1.FClass.focus();
return false;
}

if (document.form1.FnClass.value.length ==0)
{
alert('请选择小类');
document.form1.FnClass.focus();
return false;
}

if (document.form1.FItem.value.length ==0)
{
alert('请选择细目');
document.form1.FItem.focus();
return false;
}

}

</script>

<!------------------------------------------------------------------------------------------------------->
<body>
<form name="form1" method="post" action="6.asp" >
三级联动:

<%
Dim Count1,RsClass1,sqlClass1
set RsClass1=server.createobject("adodb.recordset")
sqlClass1="select * from F_Class"
RsClass1.open sqlClass1,conn,1,1
%>
<select name="FClass" onChange="Changeselect1(this.value)">
<option>==请选择大类==</option>
<%
Count1 = 0
Do while not RsClass1.eof
Response.write"<option value="&rsClass1("Class_ID")&">"&rsClass1("Class_Name")&"</option>"
Count1 = Count1 + 1
RsClass1.movenext
Loop
rsClass1.close
%>
</select>

<select name="FnClass" onChange="Changeselect2(this.value)">
<option>==请选择小类==</option>
</select>

<select name="FItem">
<option>==请选择细目==</option>
</select>

<input type="submit" name="Submit" value="提交" onClick="return RegForm()"></form>

<!-- 三级联动菜单 结束 -->
</body>
</html>
http://www.52first.com/tags.asp
Storm代理
2023-07-25 广告
StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,IP... 点击进入详情页
本回答由Storm代理提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式