找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 109|回复: 2

[求助]打开页面就显示一级菜单代码分析万事具备只欠这个了

[复制链接]
发表于 2010-1-14 06:21:12 | 显示全部楼层 |阅读模式 IP:江苏扬州
如何才能一打开页面就显示一级菜单,而不需要点击“Toumh无极限菜单树”
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%

dataurl=Server.MapPath("menutree.mdb")'数据库地址
dim conn,strQuery,rs
set conn = server.CreateObject("adodb.connection")
conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&dataurl
strQuery="select * from menufun"
set rs=server.createobject("adodb.recordset")
rs.open strQuery,conn,1,1
allnum=rs.RecordCount
'取得最大的层数MaxLevel%>
<%
MaxLevel=1
for i=1 to allnum
if rs("PartLevel")>MaxLevel then
MaxLevel=rs("PartLevel")
else
MaxLevel=MaxLevel
end if
rs.movenext
next
rs.close
set rs=nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Toumh无极限菜单树</title>
<style type="text/css">
<!--
td {
font-size: 12px;
}
-->
</style>
<script language="javascript">
<!--
function divshow(cmy1,cmy2,cmy3)
file://展开/合并菜单函数
{
if(document.all("div"+cmy1+cmy2+cmy3).style.display==""){
document.all("div"+cmy1+cmy2+cmy3).style.display="none"
}else{
document.all("div"+cmy1+cmy2+cmy3).style.display=""
}
}
file://-->
</script>
</head>
<body bgcolor="#6699CC" topmargin="0">
<table border="0" cellpadding="0" cellspacing="0">
<tr onClick="javascript:divshow(1,0,1);" style="cursor:hand"><TD><img src="images/admin.gif">Toumh无极限菜单树</TD></tr>
<%
dim toumh(10) '定义用于存放菜单前显示树图片的数组,如果应用时的最大级数大于十,请扩大数组维数
call menutree(1,0,MaxLevel,1)'首次调用菜单输出函数
'第一个参数:菜单的级数
'第二个参数:父菜单的ID,一级菜单默认为零
'第三个参数:菜单的最大级数
'第四个参数:用于区分层的名称,方便实现菜单的展开合并
%>
</table>
<%
'funno 菜单的级数
'funcid 父菜单的ID,一级菜单父级ID值为0
'MaxLevel 菜单的最大级数
'divno 用于区分层的名称,方便实现菜单的展开合并
'menutree() 数形菜单输出函数
function menutree(funno,funcid,MaxLevel,divno)
dim rsfun,numfun,funcidfun
strQuery1="select * from menufun where sup_funcid='"&funcid&"'"
set rsfun=server.createobject("adodb.recordset")
rsfun.open strQuery1,conn,1,1
numfun=rsfun.RecordCount
response.Write("<tr><td>")
response.Write("<div id='div"&funno&funcid&divno&"' style='display:none'>")'输出层,并根据相关参数给层定义唯一的ID名称
response.Write("<table border='0' cellpadding='0' cellspacing='0'>")
for j=1 to numfun
funcidfun=rsfun("funcid")
if j=numfun then '判断是否是本级菜单的最后一个
toumh(funno)="space.gif" '是则输出空白图片space.gif
else
toumh(funno)="line_v.gif" '否则输出竖线图片line_v.gif
end if
'判断是否有下级菜单
strQuery2="select * from menufun where sup_funcid='"&funcidfun&"'"
set rsfun2=server.createobject("adodb.recordset")
rsfun2.open strQuery2,conn,1,1
numfun2=rsfun2.RecordCount
'如果numfun2>0则有,反之则无
if numfun2 > 0 then
response.Write("<tr onClick='javascript:divshow("&funno+1&","&funcidfun&","&j&");' style='cursor:hand'>")
'用单击事件调用展开/合并菜单函数
else
response.Write("<tr style='cursor:hand'>")
end if
response.Write("<td>")
if numfun2 > 0 then
treeico="open_normal.gif"
if j=numfun then
treeico="open_end.gif"
end if
else
treeico="none_normal.gif"
if j=numfun then
treeico="none_end.gif"
end if
end if
for m=1 to cint(funno)-1 '根据当前菜单的级数输出菜单前的数形图片
response.Write("<img src='images/"&toumh(m)&"' align='absMiddle'>")
next
if not rsfun("enable") then '判断菜单项是否可用,不可用的菜单名用#FF0000色显示

response.Write("<img src='images/"&treeico&"' align='absMiddle'><font color='#ff0000'><a style='text-decoration: none' href=nsr_edit.asp?funcid="&rsfun("funcid")&"&amp;funcname="&rsfun("funcname")&">"&rsfun("funcname")&"</font>")'输出不可用菜单名

else

response.Write("<img src='images/"&treeico&"' align='absMiddle'><a style='text-decoration: none' href=nsr_edit.asp?funcid="&rsfun("funcid")&"&amp;funcname="&rsfun("funcname")&">"&rsfun("funcname"))'输出可用菜单名
end if
response.Write("</td>")
response.Write("</tr>")
if cint(funno)<cint(MaxLevel) then
call menutree(cint(funno)+1,funcidfun,MaxLevel,j) '递归调用 menutree()函数
end if
rsfun.movenext
next
'response.Write("</td></tr>")
response.Write("</table></div>")
response.Write("</td></tr>")
end function
%>
<!-- 程序中未能改变菜单展开/合并时的图片的属性,有兴趣的网友可以自己添加该功能 -->
<!--</body> -->
</html>
发表于 2010-1-22 05:05:10 | 显示全部楼层 IP:江苏苏州
楼主,你写得实在是太好了。我惟一能做的,就只有把这个帖子顶上去这件事了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 17:24 , Processed in 0.314891 second(s), 15 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表