您现在的位置:软界网技术中心WEB开发ASP > 技术显示
无限级分类
2005-9-13 0:00:00   网友评论       阅读次数 点此评论
   比较简单的一个页面,类似csdn论坛在ns下的左边列表
描述:
1.
数据名:tree.mdb
表名:tree
表结构:id(自编)pid(数字)content(文本)link(文本)
2.
图片:endnode.gifcollapsed.gifback.gif(均在img目录下,可自行修改)
3.
代码:
<!--#includefile='conn.inc'-->
<HTML>
<HEAD>
<metahttp-equiv='Content-Type'content='text/html;charset=gb2312'>
<METANAME='GENERATOR'Content='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>
<divclass='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'<divclass=’node’nowrap=true><ahref=’'&parentHref&'’onfocus=’blur()’><imgsrc=’'&imgFolder&'back.gif’border=0></a><ahref=’'&parentHref&'’>上一级目录</a></div>'&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'<divclass=’node’nowrap=true><ahref=’'&href&'’onfocus=’blur()’><imgsrc=’'&img&'’border=0></a>'&link&'</div>'
rs.movenext
loop
rs.close:setrs=nothing
endif
endfunction
conn.close:setconn=nothing
%>
</div>
</nobr>
</BODY>
</HTML>

conn.inc:
<%
dimconn
setconn=Server.CreateObject('ADODB.Connection')
conn.Open'Provider=Microsoft.Jet.OLEDB.4.0;DataSource='&Server.mappath('tree.mdb')&';PersistSecurityInfo=False'
%>
4.测试:ie6,ns7,mozilla下测试通过  
      来源: 作者:
 
【评论查看】
更多关于 无限级分类  的技术