<HTML>
<HEAD>
<style type="text/css">
<!--
.aa {
font-size: 12px;
color: #000000;
text-align: center;
vertical-align: middle;
letter-spacing: 0px;
word-spacing: 0px;
}
body,td,th {
font-size: 12px;
font-family: 宋体;
}
body {
background-color: #dee3f7;
margin-left: 0px;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<body >
<%
dim cn,rs,SQL ,Para,NumChild
dim SD,GD'定义深度广度
set cn=server.CreateObject("ADODB.connection")
set rs=server.createobject("ADODB.recordset")
set rs1=server.createobject("ADODB.recordset")
cn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db.mdb")
SQL="SELECT ID,Name,HyperLink,(len(ID)+1)/2 as SD,RIGHT(ID, 1) AS GD FROM tree order by ID"
rs.open SQL,cn,1,1
do while not rs.EOF
SD=rs("SD")
if SD>5 then SD=5 '深度
GD= asc(rs("GD"))-96
if GD>10 then GD=10 '广度
SQL="Select ID from tree where ID like '" & rs("ID") & "_%' and ID<>'" & rs("ID") & "' order by ID"
Para=rs("ID") & "|"
NumChild=0
rs1.open SQL,cn, 1,1
NumChild=rs1.RecordCount
do while not rs1.EOF
Para =Para & rs1("ID") & "|"
rs1.MoveNext
loop
Para=cstr(trim(left(Para,len(Para)-1)))
rs1.Close
%>
<table id="T<%=rs("ID")%>" border=1 cellpadding=0 cellspacing=0 bordercolor="#DEE3F7" class="aa" abbr="<%=Para%>" summary=<%=checkid(rs("ID"))%> style="cursor:hand" onClick='vbs:subtree "<%=Para%>"' >
<tr>
<td width="<%=17+checkid(rs("ID"))*20%>" height="17" align="right">
<table width="17" height="17" border="1" cellpadding="0" cellspacing="3" bordercolor="#DEE3F7">
<tr>
<td align="center" valign="middle" bordercolor="#000000" id="R<%=rs("ID")%>" style="font-size:9" >
<%if NumChild=0 then Response.Write "." else Response.Write "+"%>
</td>
</tr>
</table>
</td>
<td>
<img width="16" height="16" src="tree/<%=SD%>/<%=GD%>.gif">
</td>
<td height="17" nowrap bordercolor="#FFFFFF" onMouseOver="vbs:me.bgcolor='#CCCCCC':me.bordercolor='#999999'" onMouseOut="vbs:me.bgcolor='#DEE3F7':me.bordercolor='#ffffff'" title="<%=rs("ID")%>" onclick='vbs:window.location.href="<%=rs("HyperLink")%>"'>
<%=rs("Name")%>
</td>
</tr>
</table>
<% rs.MoveNext
loop
rs.Close
cn.Close
set rs=nothing
set rs1=nothing
set cn=nothing
function checkid(x)
checkid=Ubound(split(x,"_"))
end function
%>
</body >
<script language=VBS>
sub subtree(Client_para)
if instr(Client_para,"|")=0 then exit sub
Myarray=split(Client_para,"|")
Mytext=trim(eval("R" & Myarray(0) & ".innertext") )
select case Mytext
case "+"
document.all.item("R" & Myarray(0)).innertext="-"
for i=1 to ubound(Myarray)
if eval("T" & Myarray(i) & ".summary")-eval("T" & Myarray(0) & ".summary")=1 then
document.all.item("T" & Myarray(i)).style.display="block"
end if
if eval("T" & Myarray(i) & ".summary")-eval("T" & Myarray(0) & ".summary")>1 then
document.all.item("T" & Myarray(i)).style.display="none"
end if
next
case "-"
document.all.item("R" & Myarray(0)).innertext="+"
for i=1 to ubound(Myarray)
if eval("T" & Myarray(i) & ".summary")-eval("T" & Myarray(0) & ".summary")>=1 then
document.all.item("T" & Myarray(i)).style.display="none"
if eval("R" & Myarray(i) & ".innertext")="-" then
document.all.item("R" & Myarray(i)).innertext="+"
end if
end if
next
end select
set Myarray=nothing
end sub
Sub document_onselectstart
document.selection.clear
End Sub
if isobject(eval("Ta")) then
subtree document.all("Ta").abbr '一次也不执行为全展开
subtree document.all("Ta").abbr '执行1次为只显示根目录
subtree document.all("Ta").abbr '3次为显示根目录下第一层
end if
</script>
</HTML>