//********************** index.asp ************************//
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Option Explicit%>
<%
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
%>
|
<%
Set rs = Nothing
Set conn = Nothing
%>
///****************** subtree.asp *********************//
<%Option Explicit%>
function NodeClass(id,Content,strLink,iChildren)
{
//this.id=parseInt(id);
this.id=id;
this.Content=Content;
this.strLink=strLink;
this.iChildren=iChildren;
//this.iChildren=parseInt(iChildren);
}
var ArrNode = new Array();
<%
Dim conn,rs,s,cls,href,Open
Dim nodeid,i
nodeid = Request.QueryString("id")
'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=" & nodeid & "",conn,1,3
i=0
Do While Not rs.EOF
%>
ArrNode[<%=i%>] = new NodeClass(<%=rs("id")%>,'<%=trim(rs("content"))%>','<%=trim(rs("link"))%>',<%=rs("children")%>);
<%
i=i+1
rs.MoveNext
Loop
Set rs = Nothing
%>
parent.ArrToHtml(ArrNode,'<% = nodeid %>');
-->
<%
Set conn = Nothing
%>
//********************* node.htc *********************//
function fos(){
if(style.backgroundColor!='#ffffff'){
style.color="#000000"
style.border="1 solid #888888"
style.backgroundColor='#DDDDDD'
}
else
{style.color="#000000"
style.border="1 solid #999999"
style.backgroundColor='#ffffff'
}
}
function blu(){
if(style.backgroundColor!='#ffffff'){
style.color="#000000"
style.border="1 solid #f2f2f2"
style.backgroundColor='#f2f2f2'
}
else
{style.color="#000000"
style.border="1 solid #999999"
style.backgroundColor='#ffffff'
}
}
function st(){
return false;
}
//*************************** 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

