表结构
id int
MenuName nvarchar 50
MenuUrl nvarchar 255
ParentID int
Step int
<!--#include file="../inc/conndb.asp"-->
<%
'==============================================
' 数据源
'==============================================
dim rs,sql,rscount
set rs=server.CreateObject("ADODB.recordset")
sql="select * from menu order by id asc"
rs.open sql,conn,1,1
rscount=rs.recordcount
'==============================================
' 将数据存入数组
'==============================================
dim menu(100,3) '需要按记录条数改动
dim ItemString
for i=0 to rscount-1
if rs.eof or rs.bof then exit for
if trim(rs("MenuUrl"))<>"" then
ItemString="<a href='"&rs("MenuUrl")&"' target='main'>"&rs("MenuName")&"</a>"
else
ItemString=rs("MenuName")
end if
menu(i,0)=rs("ID")
menu(i,1)=ItemString
menu(i,2)=rs("ParentID")
menu(i,3)=rs("Step")
rs.movenext
next
'==============================================
' 实现Menu
'==============================================
dim css '样式
dim ourstr,stepinfo
sub GetMenu(parentid)
for j=0 to ubound(menu,1)
if parentid=menu(j,2) then
stepinfo=menu(j,3)
css="step"&stepinfo
'控制输出样式
if cint(stepinfo)=1 then
outstr="<div class="""&css&""" οnmοuseοver=""this.style.backgroundColor='#DEE7FF';"" οnmοuseοut=""this.style.backgroundColor='#F1F1F1'"" align='left'><img src='../pic/bullet.gif'>"&menu(j,1)&"</div>"
elseif cint(stepinfo)=2 then
outstr="<div class="""&css&""" οnmοuseοver=""this.style.backgroundColor='#DEE7FF';"" οnmοuseοut=""this.style.backgroundColor='#F1F1F1'"" align='left'>"&menu(j,1)&"</div>"
else
outstr="<div class="""&css&""" align='left'>"&menu(j,1)&"</div>"
end if
response.Write(outstr)
if menu(j,0)<>"" then
GetMenu menu(j,0)
end if
end if
next
end sub
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>menu</title>
<style type="text/css">
<!--
body { margin:0px; font:normal 12px 宋体;
SCROLLBAR-FACE-COLOR: #799AE1; SCROLLBAR-HIGHLIGHT-COLOR: #799AE1;
SCROLLBAR-SHADOW-COLOR: #799AE1; SCROLLBAR-DARKSHADOW-COLOR: #799AE1;
SCROLLBAR-3DLIGHT-COLOR: #799AE1; SCROLLBAR-ARROW-COLOR: #FFFFFF;
SCROLLBAR-TRACK-COLOR: #AABFEC;
}
div.step0 {
background-color: #037BC2;
height: 18px;
width: 150px;
font-weight: bold;
color: #FFFFFF;
text-align: center;
}
div.step1 {
height: 18px;
cursor: hand;
padding-left: 10px;
}
div.step2 {
height: 18px;
cursor: hand;
padding-left: 40px;
}
div {
font-size: 12px;
}
table{
font-size: 12px;
}
a:link {
color: #002084;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #002084;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
.kuang {
border: 1px solid #5582D2;
background-color: #f1f1f1;
}
-->
</style>
</head>
<body bgcolor="#8CAAE6">
<br>
<table width="160" border="0" align="center" cellpadding="0" cellspacing="0" class="kuang">
<tr>
<td height="8" align="center" bgcolor="#002F5E"><img src="../pic/dot.gif" width="1" height="1"></td>
</tr>
<tr>
<td height="25" align="center"><span class="menu_title"><a href="main.asp" target=main><b>管理首页</b></a> | <a href="../login/logout.asp" target=_top><b>退出管理</b></a><a href="menu_list.asp" target=main><b></b></a></span></td>
</tr>
<tr>
<td align="center"><% call GetMenu(0)%></td>
</tr>
</table>
<br>
</body>
</html>
<%
'==============================================
'???????????????????? 数据源
'==============================================
dim rs,sql,rscount
set rs=server.CreateObject("ADODB.recordset")
sql="select * from menu order by id asc"
rs.open sql,conn,1,1
rscount=rs.recordcount
'==============================================
'?????将数据存入数组
'==============================================
dim menu(35,3)?'需要按记录条数改动
dim ItemString
for i=0 to rscount-1
?if rs.eof or rs.bof then exit for
?if trim(rs("MenuUrl"))<>"" then
?ItemString=""&rs("MenuName")&""
?else
?ItemString=rs("MenuName")
?end if
?menu(i,0)=rs("ID")
?menu(i,1)=ItemString
?menu(i,2)=rs("ParentID")
?menu(i,3)=rs("Step")
?rs.movenext
next
'==============================================
'?????实现Menu
'==============================================
dim css?'样式
sub GetMenu(parentid)
?for j=0 to ubound(menu,1)
??if parentid=menu(j,2) then
??css="step"&menu(j,3)
??response.Write(""&menu(j,1)&"
")
??if menu(j,0)<>"" then
???GetMenu menu(j,0)
??end if
??end if
?next
?
end sub
%>
copyright by Lonz