首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

怎么修改以上代码使其能实现 无限级 动态树形菜单

2012-09-06 
如何修改以下代码使其能实现 无限级 动态树形菜单!--# include file admin_conn.asp --SCRIPT langua

如何修改以下代码使其能实现 无限级 动态树形菜单
<!--# include file = admin_conn.asp -->
<SCRIPT language=javascript1.2>
//parent.document.title='<%'=Dvbbs.Forum_info(0)%>';
function showsubmenu(ss,ii,aa,openimg,closeimg)
{
var menuobjedt=document.getElementById(ss);
if (menuobjedt)
{
 if (menuobjedt.style.display=="none") 
  {menuobjedt.style.display="";
  document.getElementById(ii).src="treepic/nofollow.gif";
  document.getElementById(ii).alt="关闭菜单";
  document.getElementById(aa).src="treepic/"+openimg;
  document.getElementById(aa).alt="关闭菜单";
}
 else
  {menuobjedt.style.display="none"; 
document.getElementById(ii).src="treepic/plus.gif";
document.getElementById(ii).alt="展开菜单";
document.getElementById(aa).src="treepic/"+closeimg;
document.getElementById(aa).alt="展开菜单";
  }
}
}
function reloadpage(){
parent.window_left.location.reload();
}
</SCRIPT>


<%
if trim(request.QueryString("lm"))<>"" then
lm_tree=trim(request.QueryString("lm"))
lm_tree2=trim(request.QueryString("lm2"))
lm_t=trim(request.QueryString("lm_t"))
'response.Write(lm_t)
else
lm_tree=rs("lm")
if rs("lm3")<>"0" then
lm_tree2=rs("lm3")
elseif rs("lm2")<>"0" then
lm_tree2=rs("lm2")
else
lm_tree2=rs("lm")
end if
lm_t=rs("lm2")
end if
zblb="<table cellpadding=0 cellspacing=0 style='width:100%' >"

sql = "select id,lm from lm where id="&lm_tree&""
Set rs_tree = Server.CreateObject("ADODB.RecordSet")
rs_tree.Open sql,conn,1,1
if not rs_tree.eof then

  zblb=zblb&"<tr>"
  zblb=zblb&"<td width=100% class=tablebody2>"
zblb=zblb&"<img src=treepic/nofollow.gif >"
zblb=zblb&"<img src=treepic/index.gif >"
zblb=zblb&"<b><a href=news_more.asp?lm="&rs_tree("id")&"&lm2="&rs_tree("id")&"><font color=#000000>"&rs_tree("lm")&"</font></a></b>"
zblb=zblb&"</td>"
  zblb=zblb&"</tr>"

sql = "select id,lm2 from lm where lmid='"&rs_tree("id")&"'"
Set rs1_tree = Server.CreateObject("ADODB.RecordSet")
rs1_tree.Open sql,conn,1,1
if rs1_tree.recordcount=0 then
'zblb=zblb&"<tr><td class=tablebody1 align=center vAlign=top><font color=#999999>暂时无子栏目</font></td></tr>"
zblb=zblb&"<tr><td>"
zblb=zblb&"<table cellpadding=0 cellspacing=0 align=center width='100%'>"
zblb=zblb&"<tr><td width=15 background=treepic/i.png></td>"
zblb=zblb&"<td class=tablebody1 width=15 background=treepic/l.png></td>"
zblb=zblb&"<td class=tablebody1 align=left vAlign=top><font color=#999999>暂时无子栏目</font></td>"
zblb=zblb&"</tr>"
zblb=zblb&"</table>"
zblb=zblb&"</td></tr>"
else
j=0
do while not rs1_tree.eof

menuname="board"&j

zblb=zblb&"<tr>"
zblb=zblb&"<td>"
zblb=zblb&"<table cellpadding=0 cellspacing=0 align=center width='100%'>"


zblb=zblb&"<tr>"
zblb=zblb&"<td class=tablebody1 width=15 background=treepic/i.png></td>"
zblb=zblb&"<td class=tablebody1 align=left vAlign=top onclick=showsubmenu('submenu"&menuname&"','subimg"&menuname&"','aimg"&menuname&"','openfolder.png','closedfolder.png')><img src=treepic/plus.gif id=subimg"&menuname&" alt=展开菜单><img src=treepic/closedfolder.png id=aimg"&menuname&" alt=展开菜单><a href=news_more.asp?lm="&rs_tree("id")&"&lm2="&rs1_tree("id")&">"
if cstr(lm_tree2)=cstr(rs1_tree("id")) then
zblb=zblb&"<font color=red>"&rs1_tree("lm2")&"</font>"

else

zblb=zblb&rs1_tree("lm2")
end if

zblb=zblb&"</a></td></tr>"
zblb=zblb&"</table>"
zblb=zblb&"</td>"
zblb=zblb&"</tr>"
'+++++++++++++++++++++++++++++++++++++++++++k开始+++++++++++++++++++++++++++++++++++++++++++++
sql = "select id,lm3 from lm where lmid='"&rs1_tree("id")&"'"
Set rs2_tree = Server.CreateObject("ADODB.RecordSet")
rs2_tree.Open sql,conn,1,1
'提取文章列表 
sql="select * from news where lm='"&rs1_tree("id")&"' or lm2='"&rs1_tree("id")&"' or lm3='"&rs1_tree("id")&"' order by xxsx"
Set rs_news = Server.CreateObject("ADODB.RecordSet")
rs_news.Open sql,conn,1,1
if rs2_tree.recordcount=0 then
zblb=zblb&"<tr><td style=display:none id='submenu"&menuname&"'>"
zblb=zblb&"<table cellpadding=0 cellspacing=0 align=center width='100%'>"

zblb=zblb&"<tr><td width=15 background=treepic/i.png></td>"
zblb=zblb&"<td class=tablebody1 width=15 background=treepic/l.png></td>"
zblb=zblb&"<td class=tablebody1 align=left vAlign=top><font color=#999999>暂时无子栏目</font></td>"
zblb=zblb&"</tr>"
'显示有没有文章
if rs_news.recordcount=0 then
zblb=zblb&"<tr><td width=15 background=treepic/i.png></td>"
zblb=zblb&"<td class=tablebody1 width=15 background=treepic/l.png></td>"
zblb=zblb&"<td class=tablebody1 align=left vAlign=top><font color=#999999>暂时无文章</font></td>"
zblb=zblb&"</tr>"
else
do while not rs_news.eof
'zblb=zblb&"<tr><td width=15 background=treepic/i.png></td>"
'zblb=zblb&"<td class=tablebody1 width=15 background=treepic/l.png></td>"
'zblb=zblb&"<td class=tablebody1 align=left vAlign=top><img src=treepic/bookclose.gif border=0><a href=News_View.asp?NewsID="&rs_news("id")&">"&rs_news("title")&"</a></img></td>"
'zblb=zblb&"</tr>"
rs_news.movenext
loop
end if
'文章显示完
zblb=zblb&"</table>"
zblb=zblb&"</td></tr>"
else
'i=0
zblb=zblb&"<tr>"
if cstr(lm_t)=cstr(rs1_tree("id")) then
zblb=zblb&"<td id='submenu"&menuname&"'>"
else
zblb=zblb&"<td style=display:none id='submenu"&menuname&"'>"


end if
zblb=zblb&"<table cellpadding=0 cellspacing=0 align=center width='100%'>"
do while not rs2_tree.eof
zblb=zblb&"<tr><td width=15 background=treepic/i.png></td>"
zblb=zblb&"<td class=tablebody1 width=15 background=treepic/i.png></td>"
zblb=zblb&"<td class=tablebody1 align=left vAlign=top><img src=treepic/closedfolder.png border=0><a href=news_more.asp?lm="&rs_tree("id")&"&lm2="&rs2_tree("id")&"&lm_t="&rs1_tree("id")&">"
if cstr(lm_tree2)=cstr(rs2_tree("id")) then
zblb=zblb&"<font color=red>"&rs2_tree("lm3")&"</font>"
else
zblb=zblb&rs2_tree("lm3")
end if
zblb=zblb&"</a></td></tr>"
'显示有没有文章
if rs_news.recordcount=0 then
zblb=zblb&"<tr><td width=15 background=treepic/i.png></td>"
zblb=zblb&"<td class=tablebody1 width=15 background=treepic/l.png></td>"
zblb=zblb&"<td class=tablebody1 align=left vAlign=top><font color=#999999>暂时无文章</font></td>"
zblb=zblb&"</tr>"
else
do while not rs_news.eof
'zblb=zblb&"<tr><td width=15 background=treepic/i.png></td>"
'zblb=zblb&"<td class=tablebody1 width=15 background=treepic/l.png></td>"
'zblb=zblb&"<td class=tablebody1 align=left vAlign=top><img src=treepic/bookclose.gif border=0><a href=News_View.asp?NewsID="&rs_news("id")&">"&rs_news("title")&"</a></img></td>"
'zblb=zblb&"</tr>"
rs_news.movenext
loop
end if
'文章显示完

rs2_tree.movenext
loop
zblb=zblb&"</table>"
zblb=zblb&"</td>"
zblb=zblb&"</tr>"
end if

rs2_tree.close
set rs2_tree=nothing
'++++++++++++++++++++++++++++++++++++++++++++结束++++++++++++++++++++++++++++++++++++++++++++++
rs1_tree.movenext
j=j+1
loop
end if
rs1_tree.close
set rs1_tree=nothing
end if
rs_tree.close
set rs_tree=nothing
zblb=zblb&"</table>"
'response.Write(zblb)
%>


[解决办法]
代码这么多,看着头疼,全部都是向左对齐,怎么看?直接说要点。

热点排行