如何制做菜单?(高分请教!100分!) http://www.csdn.net/expert/topic/530/530401.xml?temp=.8081018 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Cool Menu!!http://go6.163.com/colorweb/index6.htm http://lucky.myrice.com/main.htmlhttp://lucky.myrice.com/service/log.htmMore Cool!!! 使用asp 结合数据库实现不限级数的弹出菜单(原创)——流行技术 不死鸟下面是我写的一个程序,因为觉得比较好,值得借鉴, 所以放了上来, 如果看的不清楚,请点击引用 如果转载,请注明出自考网(www.kaowang.com)流行技术论坛(不死鸟 QQ 33054474) 谢谢 < !-- #include virtual='Include/database.asp' --> < % set rs=Server.CreateObject("ADODB.RecordSet") sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE (parent_id = (SELECT id FROM enter_individual WHERE menu_flag = 'root' )) " '查询得到根节点 rs.Open sql,conn,1,1 Response.Write "< table width=100% border=0 cellspacing=1 cellpadding=0 align=center>< tr bgcolor=#3399CC valign=bottom align=center>" sumnum=rs.RecordCount myArray=rs.GetRows() rs.Close () widd=780/sumnum '从一级子菜单数目判断弹出菜单x坐标的递增像素 dim i i=0 defaultbgcolor="#3399cc" '指定默认底色 defaultcolor="#ffffff" '指定默认字体颜色 defaultlink="#" '指定默认链接 posit_x=0 'x位置 flag=1 '标志,作为菜单弹出方向 1表示向右,0表示向左 'Response.Write myArray(4,6) while i Response.Write "< td height=20 bgcolor="&myArray(2,i)&" width="&widd&">< a href="&myArray(1,i)&" onmouseover=java script:a"&myArray(4,i)&".style.display='block' onmouseout=java script:a"&myArray(4,i)&".style.display='none' >< font color="&myArray(3,i)&" >"&myArray(0,i)&"< /a>< /td>" '----------------------------------------------- i=i+1 Wend Response.Write "< /tr>< /table>" i=0 while i posit_y=100 'y位置回到原位 If i>=(sumnum/2) Then '如果菜单进入右半部分,则弹出转向 flag=0 End If '调用GetSubMenu 函数 设置该项一级菜单的下级菜单,以myArray(4,i) 即菜单id作为下级菜单所在div 的id GetSubMenu myArray(4,i),posit_x,posit_y posit_x=posit_x+widd '下一个一级菜单的子菜单的 x坐标值增加一个单位 i=i+1 Wend '使用递规算法的到下级菜单的函数 'parent_id 父 id; posit_x 弹出层的左边位置; posit_y 弹出层的离上面位置; Function GetSubMenu(parent_id,posit_x,posit_y) dim myArray dim sumnum dim i '查询子菜单的下级菜单 sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE parent_id = "&parent_id&" AND user_id = '"&userid&"'" rs.Open sql,conn,1,1 '如果下级菜单不存在,则层数减一 ,关闭数据库链接,建立一个以父id为div id的空层,然后返回 If rs.EOF=true Then level=level-1 rs.Close () 'Response.Write parent_id Response.Write "< div id='a"&parent_id&"' style='position: absolute; top: 4; left: -1; display: none; width: 0; height: 0'>< /div>" Else '如果存在取到数据库数据,并调用SetSubMenu显示菜单 sumnum=rs.RecordCount myArray=rs.GetRows() rs.Close () SetSubMenu myArray,sumnum,parent_id,posit_x,posit_y '对数据进行循环,递规调用GetSubMenu i=0 while i< sumnum posit_y=posit_y*1+20 '递规一次posit_y 加一个单位, if level=0 Then '如果级数减到0 则回到1 level=1 End If 'If flag=1 Then 'GetSubMenu myArray(4,i),posit_x+level*widd,posit_y-level*20 '递规调用GetSubMenu x,y坐标延伸 level 个单位 'End If If flag=0 Then GetSubMenu myArray(4,i),posit_x-level*widd,posit_y-level*20 '递规调用GetSubMenu x,y坐标延伸 level 个单位 Else GetSubMenu myArray(4,i),posit_x+level*widd,posit_y-level*20 '递规调用GetSubMenu x,y坐标延伸 level 个单位 End If i=i+1 Wend End If End Function '设置子菜单函数 'myArray 菜单数据 ,sumnum 数组大小 ,parent_id 层的id ; 'posit_x 弹出层的左边位置; posit_y 弹出层的离上面位置; Function SetSubMenu (myArray,sumnum,parent_id,posit_x,posit_y) dim i parent_id="a"&parent_id '父菜单id前面加上a 作为层的id hh=sumnum*20 '数组大小乘以20作为层的高度 Response.Write "< DIV onmouseover=java script:"&parent_id&".style.display='block' onmouseout=java script:"&parent_id&".style.display='none' ID='"&parent_id&"' STYLE='position: absolute; top:"&posit_y&"; left:"&posit_x&"; height:"&hh*1&"; width: "&widd&"; display:none;vertical-align: top'>< table width=100% border=0 cellspacing=1 cellpadding=0 >" i=0 While i myArray(0,i)=Trim(myArray(0,i)) myArray(1,i)=Trim(myArray(1,i)) myArray(2,i)=Trim(myArray(2,i)) myArray(3,i)=Trim(myArray(3,i)) If myArray(2,i)="" Then myArray(2,i)=defaultbgcolor End If If myArray(3,i)="" Then myArray(3,i)=defaultcolor End If If myArray(1,i)="" Then myArray(1,i)=defaultlink End If Response.Write "< tr align=center >< td width=100% height=20 bgcolor="&myArray(2,i)&" onmouseover=java script:"&parent_id&".style.display='block';a"&myArray(4,i)&".style.display='block' onmouseout=java script:a"&myArray(4,i)&".style.display='none'>< a href='"&myArray(1,i)&"'>< font color="&myArray(3,i)&" >"&myArray(0,i)&"< /font>< /a>< /td>< /tr>" i=i+1 Wend Response.Write " < /table> < /DIV>" End Function Set rs=nothing conn.Close () Set conn=nothing % > -------------------------------------------------------------------------------- javascript语句疑问 html如何将连接的内容作为参数传递给js函数? Extjs 问题 关于select的名称特殊命名后的值读取方法,难呀 求一正则表达式 如何获取地址栏参数? 如何把一个文本框里的图片名循环出来并以图片显示? JQuery Uploadify隐藏浏览按钮后,通过JS触发Uploadify的Click事件,不能上传文件 用javascript可以取到注册表中的信息吗? 关键问题!(急啊) 在电子邮件中打开链接的问题 关于如何在A窗口中关闭在A窗口中弹出的b窗口??请求帮助。。急。。。。。。
http://go6.163.com/colorweb/index6.htm
http://lucky.myrice.com/service/log.htmMore Cool!!!
不死鸟
下面是我写的一个程序,因为觉得比较好,值得借鉴,
所以放了上来,
如果看的不清楚,请点击引用
如果转载,请注明出自考网(www.kaowang.com)流行技术论坛(不死鸟 QQ 33054474)
谢谢 < !-- #include virtual='Include/database.asp' -->
< %
set rs=Server.CreateObject("ADODB.RecordSet") sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE (parent_id = (SELECT id FROM enter_individual WHERE menu_flag = 'root' )) " '查询得到根节点
rs.Open sql,conn,1,1
Response.Write "< table width=100% border=0 cellspacing=1 cellpadding=0 align=center>< tr bgcolor=#3399CC valign=bottom align=center>"
sumnum=rs.RecordCount
myArray=rs.GetRows()
rs.Close ()
widd=780/sumnum '从一级子菜单数目判断弹出菜单x坐标的递增像素
dim i
i=0
defaultbgcolor="#3399cc" '指定默认底色
defaultcolor="#ffffff" '指定默认字体颜色
defaultlink="#" '指定默认链接
posit_x=0 'x位置
flag=1 '标志,作为菜单弹出方向 1表示向右,0表示向左
'Response.Write myArray(4,6)
while i Response.Write "< td height=20 bgcolor="&myArray(2,i)&" width="&widd&">< a href="&myArray(1,i)&" onmouseover=java script:a"&myArray(4,i)&".style.display='block' onmouseout=java script:a"&myArray(4,i)&".style.display='none' >< font color="&myArray(3,i)&" >"&myArray(0,i)&"< /a>< /td>"
'----------------------------------------------- i=i+1
Wend
Response.Write "< /tr>< /table>" i=0
while i posit_y=100 'y位置回到原位
If i>=(sumnum/2) Then '如果菜单进入右半部分,则弹出转向
flag=0
End If '调用GetSubMenu 函数 设置该项一级菜单的下级菜单,以myArray(4,i) 即菜单id作为下级菜单所在div 的id GetSubMenu myArray(4,i),posit_x,posit_y
posit_x=posit_x+widd '下一个一级菜单的子菜单的 x坐标值增加一个单位
i=i+1 Wend '使用递规算法的到下级菜单的函数
'parent_id 父 id; posit_x 弹出层的左边位置; posit_y 弹出层的离上面位置; Function GetSubMenu(parent_id,posit_x,posit_y)
dim myArray
dim sumnum
dim i '查询子菜单的下级菜单
sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE parent_id = "&parent_id&" AND user_id = '"&userid&"'"
rs.Open sql,conn,1,1 '如果下级菜单不存在,则层数减一 ,关闭数据库链接,建立一个以父id为div id的空层,然后返回
If rs.EOF=true Then
level=level-1
rs.Close ()
'Response.Write parent_id
Response.Write "< div id='a"&parent_id&"' style='position: absolute; top: 4; left: -1; display: none; width: 0; height: 0'>< /div>"
Else '如果存在取到数据库数据,并调用SetSubMenu显示菜单
sumnum=rs.RecordCount
myArray=rs.GetRows()
rs.Close ()
SetSubMenu myArray,sumnum,parent_id,posit_x,posit_y '对数据进行循环,递规调用GetSubMenu
i=0
while i< sumnum
posit_y=posit_y*1+20 '递规一次posit_y 加一个单位,
if level=0 Then '如果级数减到0 则回到1
level=1
End If
'If flag=1 Then
'GetSubMenu myArray(4,i),posit_x+level*widd,posit_y-level*20 '递规调用GetSubMenu x,y坐标延伸 level 个单位
'End If
If flag=0 Then
GetSubMenu myArray(4,i),posit_x-level*widd,posit_y-level*20 '递规调用GetSubMenu x,y坐标延伸 level 个单位
Else
GetSubMenu myArray(4,i),posit_x+level*widd,posit_y-level*20 '递规调用GetSubMenu x,y坐标延伸 level 个单位
End If i=i+1
Wend
End If End Function '设置子菜单函数
'myArray 菜单数据 ,sumnum 数组大小 ,parent_id 层的id ;
'posit_x 弹出层的左边位置; posit_y 弹出层的离上面位置; Function SetSubMenu (myArray,sumnum,parent_id,posit_x,posit_y)
dim i
parent_id="a"&parent_id '父菜单id前面加上a 作为层的id
hh=sumnum*20 '数组大小乘以20作为层的高度
Response.Write "< DIV onmouseover=java script:"&parent_id&".style.display='block' onmouseout=java script:"&parent_id&".style.display='none' ID='"&parent_id&"' STYLE='position: absolute; top:"&posit_y&"; left:"&posit_x&"; height:"&hh*1&"; width: "&widd&"; display:none;vertical-align: top'>< table width=100% border=0 cellspacing=1 cellpadding=0 >"
i=0
While i myArray(0,i)=Trim(myArray(0,i))
myArray(1,i)=Trim(myArray(1,i))
myArray(2,i)=Trim(myArray(2,i))
myArray(3,i)=Trim(myArray(3,i))
If myArray(2,i)="" Then
myArray(2,i)=defaultbgcolor
End If If myArray(3,i)="" Then
myArray(3,i)=defaultcolor
End If If myArray(1,i)="" Then
myArray(1,i)=defaultlink
End If
Response.Write "< tr align=center >< td width=100% height=20 bgcolor="&myArray(2,i)&" onmouseover=java script:"&parent_id&".style.display='block';a"&myArray(4,i)&".style.display='block' onmouseout=java script:a"&myArray(4,i)&".style.display='none'>< a href='"&myArray(1,i)&"'>< font color="&myArray(3,i)&" >"&myArray(0,i)&"< /font>< /a>< /td>< /tr>" i=i+1
Wend Response.Write " < /table> < /DIV>"
End Function Set rs=nothing
conn.Close ()
Set conn=nothing
% >
--------------------------------------------------------------------------------