!!寻求一份动态菜单的代码。谢谢!(在线等候!——)
自己找了一份,但是出现好多错误,自己没有改过来,代码如下:
<%
Dim Cn,Rs
Dim StrDSN, SQL1,SQL2
Set cn=Server.CreateObject("ADODB.connection")
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Set Rs2 = Server.CreateObject("ADODB.Recordset")
StrDSN = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database/db1.mdb")
Cn.Open strDSN
SQL1="select * from father"
Rs1.Open SQL1,cn,3,2
Rs1.MoveFirst
Response.Write "<SCRIPT LANGUAGE=vbs>" & chr(13)
Response.Write "public Father_Count"& chr(13)
Response.Write "Father_Count=" & rs1.RecordCount & chr(13) '将父亲的数量传给客户端
Response.Write "</SCRIPT>" & chr(13)%>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#66CCFF" style="cursor:hand">
<%do while not rs1.EOF %>
<tr>
<td width="91" bordercolor="#FFFFFF" bgcolor="#0099CC" id="father_<%=rs1("father_id")%>" onclick="vbs:call aaa(me)"><%=rs1("father_name")%> </td>
</tr>
<% SQL2="select * from child where father_id='" & rs1("father_id")&"'"
rs2.Open SQL2,cn,3,2
do while not rs2.EOF %>
<tr id="child_<%=(rs1("father_id") & "_" & rs2("child_id"))%>" style="display:none" >
<td bordercolor="#FFFFFF" onclick="vbs:msgbox '现在执行
-<%=rs2("child_name")%>!'"> <%=rs2("child_name")%></td>
</tr>
<%rs2.MoveNext
loop
rs2.Close %>
<% rs1.MoveNext
loop
rs1.Close
Cn.Close
set rs1=nothing
set rs2=nothing
set cn=nothing
%>
</table>
<SCRIPT LANGUAGE=vbs>
sub ShowChild(x,y)'显示隐藏子过程,x代表父亲id,y代表显示1还是隐藏0
dim n '用来循环的东西
n=1
do
if isobject(eval("child_" & x & "_" & n))then
if y=1 then
window.execScript "child_" & x & "_" & n & ".style.display='block'","vbs"'显示
else
window.execScript "child_" & x & "_" & n & ".style.display='none'" ,"vbs"'隐藏
end if
else
exit do
end if
n=n+1
loop
end sub
sub aaa(obj)
dim j'用来循环的东西
for j=1 to Father_Count
if j=cint(right(obj.id,len(trim(obj.id))-7)) then
ShowChild j,1'显示自己子菜单
else
ShowChild j,0'隐藏其余的子菜单
end if
next
end sub
ShowChild 1,1
</SCRIPT>
还请各位帮忙看一下!谢谢!