请教yms123:
yms123你好!看了你对二级菜单的答复及源代码,非常感谢。但是我为了好看一些(主要是为了看起来方便,比较习惯这样的方式),进行了修改,但是修改后拿取出来的子菜单却只能显示第一条(response出来记录数也为三条),其他的不能显示。请帮忙,谢谢!代码如下:
<%
dim cn,rs,tablenum,strMenuID,I,J,strSonMenu
set cn = Server.CreateObject("Adodb.Connection")
cn.open "Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=lctdata;Data Source=localhost"
Set rs = Server.CreateObject("Adodb.Recordset")
Set rs1 = Server.CreateObject("Adodb.Recordset")
'rs.open "select A.*,B.* from Menu_Role A,Menu_Info B where Role_User='" & strLoginName & "'",cn,1,3
rs.open "select A.*,B.* from Menu_Role A,Menu_Info B where A.Role_ID=B.Menu_ID and Parent_id=0 and A.Role_User='" & strLoginName & "'",cn,1,1
%>
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
function ShowLayer(index)
{
if(this.Layer(index).style.display=="none")
{
this.Layer(index).style.display="block";
}
else
{
this.Layer(index).style.display="none";
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="41%" border="0" height="116" id="table1">
<%
if not rs.eof then
rs.movefirst
for I=1 to rs.recordcount
strSonMenu = rs("menu_id")
%>
<tr>
<td><a href=# onclick=ShowLayer(0);><%=rs("menu_name")%>菜单一</a></td>
</tr>
<%
response.write strSonMenu
if rs1.state=1 then rs1.close
rs1.Open "select * From menu_info Where Parent_id='" & strSonMenu & "'",cn,1,1
IF Not rs1.EOF Then
for j=1 to rs1.recordcount
%>
<tr>
<td>
<div style=display:none; id=Layer><img src="child.gif"><%=rs1("menu_name")%></div>
</td>
</tr>
<% rs1.MoveNext
next
End IF
rs.MoveNext
next
end if%>
</table>
</form>
</body>
</html>