无限级分类 - ASP教程_ASP编程_ASP开发技术文章 - 红黑联盟
2018-09-06 11:11
比较简单的一个页面,类似csdn论坛在ns下的左边列表
描述:
1.
数据名:tree.mdb
表名:tree
表结构:id(自编)pid(数字)content(文本)link(文本)
2.
图片:endnode.gifcollapsed.gifback.gif(均在img目录下,可自行修改)
3.
代码:
<HTML>
<HEAD>
<metahttp-equiv=Content-Typecontent=text/html;charset=gb2312>
<METANAME=GENERATORContent=MicrosoftFrontPage4.0>
<TITLE>无限级列表</TITLE>
<!--
byfason(2003-5-12)
-->
<style>
.node{
font-size:12px;
padding:0020;
margin-left:10;
height:22px;
}
img{
vertical-align:middle;
width:11px;
height:11px;
}
a{text-decoration:none;font-size:12px;color:black}
.deeptree{
width:100%;
height:100%;
backgound-color:#f2f2f2;
overflow:auto;
}
</style>
</HEAD>
<BODYbgcolor=#f2f2f2>
<nobr>
<pclass=deeptree>
<%
newid=Request.QueryString(id)
ifnewid=orCInt(newid)<0thennewid=0
ifisNumeric(newid)then
listTree(CInt(newid))
endif
functionlistTree(id)
dimrs
dimimgFolder,imgFile
dimlink,href,parentHref
dimtarget,ahref,click
target=main’所指定的框架名
imgFolder=img/’默认路径
setrs=conn.execute(select*,(selectcount(*)fromtreewherepid=T.id)aschildren,(selectpidfromtreewhereid=id)asparentfromtreeTwherepid=id)
ifnotrs.eofthen
parentHref=Request.ServerVariables(URL)?id=rs(parent)
ifid<>0thenResponse.Write<pclass=’node’nowrap=true><ahref=’parentHref’onfocus=’blur()’><imgsrc=’imgFolderback.gif’border=0></a><ahref=’parentHref’>上一级目录</a></p>VbCrLf
dowhilenotrs.eof
ifrs(children)>0then
img=imgFolder+collapsed.gif
href=Request.ServerVariables(URL)?id=rs(id)
click=onclick=location.href=’href’
else
img=imgFolder+endnode.gif
href=javascript:void(0)
endif
ifnotisNull(rs(link))then
ahref=rs(link)
else
ahref=javascript:void(0)
target=_self
endif
link=<ahref=’ahref’target=’target’title=’rs(content)’click>rs(content)</a>
Response.Write<pclass=’node’nowrap=true><ahref=’href’onfocus=’blur()’><imgsrc=’img’border=0></a>link</p>
rs.movenext
loop
rs.close:setrs=nothing
endif
endfunction
conn.close:setconn=nothing
%>
</p>
</nobr>
</BODY>
</HTML>
conn.inc:
<%
dimconn
conn.OpenProvider=Microsoft.Jet.OLEDB.4.0;DataSource=Server.mappath(tree.mdb);PersistSecurityInfo=False
%>
4.测试:ie6,ns7,mozilla下测试通过
文章标题:无限级分类 - ASP教程_ASP编程_ASP开发技术文章 - 红黑联盟
文章链接:http://soscw.com/essay/9111.html