asp二级联动菜单如何变成三级联动 急!!!
数据调用的数据库的,大家帮帮忙,在线急等。。。。。<selectname="categoryid"size="1"id="categoryid"onChange="cha...
数据调用的数据库的,大家帮帮忙,在线急等。。。。。
<select name="categoryid" size="1" id="categoryid" onChange="changelocation(document.myform.categoryid.options[document.myform.categoryid.selectedIndex].value)">
<option selected value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
<%
dim selclass
selclass=rs("categoryid")
response.write(selclass)
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
二级分类:
<select name="sortsid" >
<%rs.open "select * from sorts where categoryid="&selclass ,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("sortsid")%>"><%=rs("sorts")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("sortsid")%>"><%=rs("sorts")%></option>
<% rs.movenext
loop
end if
rs.close
%>
</select> 展开
<select name="categoryid" size="1" id="categoryid" onChange="changelocation(document.myform.categoryid.options[document.myform.categoryid.selectedIndex].value)">
<option selected value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
<%
dim selclass
selclass=rs("categoryid")
response.write(selclass)
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
二级分类:
<select name="sortsid" >
<%rs.open "select * from sorts where categoryid="&selclass ,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("sortsid")%>"><%=rs("sorts")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("sortsid")%>"><%=rs("sorts")%></option>
<% rs.movenext
loop
end if
rs.close
%>
</select> 展开
2个回答
展开全部
哎,我就辛苦点,在线给你写吧。
<script language="javascript">
function one_change()
{
var oid;
var string=new Array();
oid=forma.oneid.value;
outstring="<select name='twoid' id='twoid' onChange='two_change()'><option value='no'>请选择</option>"
<%
Set trs=server.CreateObject("adodb.recordset")
trs.open "select * from two order by orderid",conn,1,1
i=0
do while trs.eof=False
%>
string[<%=i%>]=new Array('<%=trs("oneid")%>','<%=trs("id")%>','<%=trs("twoname")%>')
<%
i=i+1
trs.movenext
loop
trs.close
Set trs=Nothing
%>
for (i=0 ;i<string.length;i++)
{
if (string[i][0]==oid)
{
outstring=outstring+"<option value='"+string[i][1]+"'>"+string[i][2]+"</option>";
}
}
outstring=outstring+"</select>";
document.all.twid.innerHTML=outstring;
document.all.thid.innerHTML="<select name='threeid' id='threeid'><option value='no'>请选择</option></select>";
}
function two_change()
{
var tid;
var strings=new Array();
tid=document.all.forma.twoid.value;
outstrings="<select name='threeid' id='threeid'><option value='no'>请选择</option>"
<%
Set trs=server.CreateObject("adodb.recordset")
trs.open "select * from three order by orderid",conn,1,1
i=0
do while trs.eof=False
%>
strings[<%=i%>]=new Array('<%=trs("twoid")%>','<%=trs("id")%>','<%=trs("threename")%>')
<%
i=i+1
trs.movenext
loop
trs.close
Set trs=Nothing
%>
for (i=0 ;i<strings.length;i++)
{
if (strings[i][0]==tid)
{
outstrings=outstrings+"<option value='"+strings[i][1]+"'>"+strings[i][2]+"</option>";
}
}
outstrings=outstrings+"</select>";
document.all.thid.innerHTML=outstrings;
//add
var tid;
var strings=new Array();
tid=document.all.forma.twoid.value;
outstrings="<select name='xiao' id='xiao'><option value='no'>请选择</option>"
<%
Set trs=server.CreateObject("adodb.recordset")
trs.open "select * from xiaoguo order by twoid",conn,1,1
i=0
do while trs.eof=False
%>
strings[<%=i%>]=new Array('<%=trs("twoid")%>','<%=trs("id")%>','<%=trs("name")%>')
<%
i=i+1
trs.movenext
loop
trs.close
Set trs=Nothing
%>
for (i=0 ;i<strings.length;i++)
{
if (strings[i][0]==tid)
{
outstrings=outstrings+"<option value='"+strings[i][1]+"'>"+strings[i][2]+"</option>";
}
}
outstrings=outstrings+"</select>";
}
</script>
<table><tr><td>这里放oneid select</td><td name="twid" id="twid">这里放twoid select</td><td name="thid" id="thid">这里放three select</td></tr></table>
晕了,快累死了。
一定要注意,在数据库里应该有三个表one ,two ,three。
<script language="javascript">
function one_change()
{
var oid;
var string=new Array();
oid=forma.oneid.value;
outstring="<select name='twoid' id='twoid' onChange='two_change()'><option value='no'>请选择</option>"
<%
Set trs=server.CreateObject("adodb.recordset")
trs.open "select * from two order by orderid",conn,1,1
i=0
do while trs.eof=False
%>
string[<%=i%>]=new Array('<%=trs("oneid")%>','<%=trs("id")%>','<%=trs("twoname")%>')
<%
i=i+1
trs.movenext
loop
trs.close
Set trs=Nothing
%>
for (i=0 ;i<string.length;i++)
{
if (string[i][0]==oid)
{
outstring=outstring+"<option value='"+string[i][1]+"'>"+string[i][2]+"</option>";
}
}
outstring=outstring+"</select>";
document.all.twid.innerHTML=outstring;
document.all.thid.innerHTML="<select name='threeid' id='threeid'><option value='no'>请选择</option></select>";
}
function two_change()
{
var tid;
var strings=new Array();
tid=document.all.forma.twoid.value;
outstrings="<select name='threeid' id='threeid'><option value='no'>请选择</option>"
<%
Set trs=server.CreateObject("adodb.recordset")
trs.open "select * from three order by orderid",conn,1,1
i=0
do while trs.eof=False
%>
strings[<%=i%>]=new Array('<%=trs("twoid")%>','<%=trs("id")%>','<%=trs("threename")%>')
<%
i=i+1
trs.movenext
loop
trs.close
Set trs=Nothing
%>
for (i=0 ;i<strings.length;i++)
{
if (strings[i][0]==tid)
{
outstrings=outstrings+"<option value='"+strings[i][1]+"'>"+strings[i][2]+"</option>";
}
}
outstrings=outstrings+"</select>";
document.all.thid.innerHTML=outstrings;
//add
var tid;
var strings=new Array();
tid=document.all.forma.twoid.value;
outstrings="<select name='xiao' id='xiao'><option value='no'>请选择</option>"
<%
Set trs=server.CreateObject("adodb.recordset")
trs.open "select * from xiaoguo order by twoid",conn,1,1
i=0
do while trs.eof=False
%>
strings[<%=i%>]=new Array('<%=trs("twoid")%>','<%=trs("id")%>','<%=trs("name")%>')
<%
i=i+1
trs.movenext
loop
trs.close
Set trs=Nothing
%>
for (i=0 ;i<strings.length;i++)
{
if (strings[i][0]==tid)
{
outstrings=outstrings+"<option value='"+strings[i][1]+"'>"+strings[i][2]+"</option>";
}
}
outstrings=outstrings+"</select>";
}
</script>
<table><tr><td>这里放oneid select</td><td name="twid" id="twid">这里放twoid select</td><td name="thid" id="thid">这里放three select</td></tr></table>
晕了,快累死了。
一定要注意,在数据库里应该有三个表one ,two ,three。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询