//********************** index.asp ************************//
<%@LANGUAGE="VBSCRIPT " CODEPAGE="936"%> <%Option Explicit%>
tree
<% Dim conn,rs Dim s,open,cls On Error Resume Next Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("tree/tree.mdb") & ";Persist Security Info=False" Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select *,(select count(*) from deeptree where parentid = T.id) as children from deeptree T where parentid=0 order by parentid",conn,1,3 %>
<% Do While Not rs.EOF If rs("children") = 0 Then s = "." open = "no" cls = "dirNode" Else s = "+" open = "false" cls = "dirclose" End If %> " class="td_node" valign="top">" onclick="expand(<%=rs("id")%>)" open="<% = open %>"><% = s %> " onclick="expand(<% = rs("id") %>)" title="<% = Trim(rs("content")) %>" href="<% = Trim(rs("link")) %>"><% = rs("content") %> <% If rs("children") > 0 Then%> " style="display: none"> <%End If%> <% rs.MoveNext Loop %>
<% Set rs = Nothing Set conn = Nothing %>
///****************** subtree.asp *********************//
<%Option Explicit%> <% Set conn = Nothing %>
//********************* node.htc *********************//
//*************************** style.css ****************//
body{font-size:12px} #txt{font-size: 12px; color: #000000; font-family: Courier New;border:1 solid #3366cc} #hrf{font-size: 12px; color: #000000; font-family: Courier New;border:1 solid #3366cc} #sb{font-size: 12px; color: #000000; font-family: Courier New;background-color:#d2e8ff;border:1 solid #3366cc;cursor:hand} .node{position:relative;left:2;height:20;padding:3 3 1 3;font-size:12px;font-family: Courier New;cursor:hand;border:1 solid #f2f2f2;behavior:url(css/node.htc)} .load{position:relative;left:2;height:20;padding:1 3 1 3;font-size:12px;font-family: Courier New;cursor:hand;border:1 solid #999999;background-color:#f2f2f2;color:#999999} .td_node{height:22px} #treedir{ } span.diropen { padding-left:2px; overflow:hidden; line-height:3px; font-size:12px; padding-top:5px; width:11px; height:11px; border:solid 1px black; background-color:#ffffff; cursor:hand; } span.dirclose { line-height:6px; font-size:9px; overflow:hidden; padding:2px; width:11px; height:11px; border:solid 1px black; background-color:#ffffff; cursor:hand; } .dirNode { font-weight:bold overflow:visible; font-size:9px; line-height:3px; padding: 1px 1px 0px 3px; width:11px; height:11px; border:solid 1px black; background-color:#ffffff; cursor:hand; }
// 把 node.htc, style.css 保存与 css 目录下. index.asp subtree.asp 放与根目录. 另新建一ACCESS数据库 tree.mdb 表deeptree 结构为 id,content, parentid,link