|a|b|
------
|2|3|
|4|2|
|5|3|
|8|3|
|6|4|
|1|5|
|7|3|
|9|2|
在b字段里有固定的4个值,由B字段用户创建的a字段用户,我想开发一个四级查询菜单:
一级|二级|三级|四级
3 2 4 6
3 5 1
2 4 6
5 1
就是把B当作上一级菜单,A当下一级菜单。从一级菜单中选择要查询B用户,在A项中查询相应的由B创建的用户并在二级菜单中列出;再在二级菜单选择要查询的用户,在A项中查询相应的由B创建的用户并在三级菜单中列出;......
如果未找到,则列出空值
如:
一级菜单先3,则二级菜单列出2、5、8、7;二级菜单选2,三级菜单列出4、9;三级菜单选4,四级菜单列出6。
一级菜单选5,二级菜单列出1,再先1的话,三级菜单是空的
用ASP如何实现呀,现在头大着呢,麻烦各位GG、JJ、DD、MM指点一下,在此谢过.....
四级联动菜单
<%
Dim Cn,Rs
Dim SQL,StrDSN
dim L:L=12\编码总长度
dim first:first=string(L,"0")
a=array(0,2,1,4,5)
Set cn=Server.CreateObject("ADODB.connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
StrDSN = "Driver={Microsoft Access Driver (*.mdb)}; DBQ="
StrDSN = StrDSN & Server.MapPath("db4.mdb")
Cn.Open strDSN
x=cint(Request("x"))+1
first=trim(Request("first"))
sub addfirst(x)
dim m:m=0\m代表祖宗字串的长度,假设根节点是12个0
for i=0 to x-1
m=m+a(i)
next
SQL="select * from tb where code like \" & left(first,m) & string(a(x),"_") & string(L-m-a(x),"0") & "\ and code<>\" & first & "\"
Rs.Open SQL,cn,3,2
if Rs.RecordCount>1 then
first=rs("code")
do while not Rs.EOF%>d.Add "<%=rs("code")%>", "<%=rs("name")%>"
<%
Rs.MoveNext
loop
end if
Rs.Close
end sub
%>
<SCRIPT LANGUAGE=vbscript >
Dim d,o \ 创建对象变量。
Set d = CreateObject("Scripting.Dictionary")
<%addfirst x%>
dim x:x=<%=x%>
dim first:first="<%=first%>"
remove x \移除
addo x \增加
sub remove(x)\移除
for each ooo in eval("parent.f.S" & x & ".options")
execScript "parent.f.S" & x & ".remove " & ooo.index,"vbs"
next
end sub
sub addo(x) \增加
for each code in d.Keys
set o=document.createElement("option")
o.text=d.Item(code)
o.value=code
execScript "parent.f.S" & x & ".add o","vbs"
next
end sub
if x <4 and eval("parent.f.S" & x & ".length")<>0 then window.location.href="Q.asp?x=" & x & "&first=" & first
</SCRIPT>
<%Cn.Close
set rs=nothing
set cn=nothing%>