这里有目录树的原代码,可是当拆叠时只能拆叠一级子目录 谢谢 解决这个问题 另开贴专送1000分不够咱们再商量,说到做到 呵呵 我急啊 http://uheart.myetang.com/treeproblem.rar为完整的文件包,里有数据库,IIS直接运行里面的页面文件就行了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://expert.csdn.net/Expert/topic/2547/2547265.xml?temp=.9461634 <!-- #include file="../Function/OpenDataBase.asp" --><%Function GetConn 'On Error Resume Next 'Dim Conn 'Set Conn = Server.CreateObject("ADODB.Connection") 'Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("teacher.MDB") 'Conn.Open Set GetConn = ConnEnd FunctionFunction WriteTree(ParentID,Prefix) Dim Rs, ThisID, SQL, ImgPath, ImgPath2, ImgPath3, HasSubItem, IsEnd, ThisPrefix Set Rs = Server.CreateObject("ADODB.RecordSet") SQL = "Select * From tbl_Tree Where I_Rank=" & ParentID Rs.Open SQL, GetConn, 1 For i = 1 To Rs.RecordCount HasSubItem = GetConn.Execute("Select Count(*) From tbl_Tree Where I_Rank=" & Rs("I_RecordID"))(0) If i = Rs.RecordCount Then '最后一个节点 If HasSubItem > 0 Then '有子节点 ImgPath = "Lessons/TreeImages/Line_plastnode.gif" ImgPath2 = "Lessons/TreeImages/Line_mlastnode.gif" ImgPath3 = "Lessons/TreeImages/OpenediDefFolder.gif" Else '没有子节点 ImgPath = "Lessons/TreeImages/Line_lastnode.gif" ImgPath2 = "Lessons/TreeImages/Line_lastnode.gif" ImgPath3 = "Lessons/TreeImages/iText.gif" End If IsEnd = True Else '非最后一个节点 If HasSubItem > 0 Then '有子节点 ImgPath = "Lessons/TreeImages/Line_pnode.gif" ImgPath2 = "Lessons/TreeImages/Line_mnode.gif" ImgPath3 = "Lessons/TreeImages/OpenediDefFolder.gif" Else '没有子节点 ImgPath = "Lessons/TreeImages/Line_node.gif" ImgPath2 = "Lessons/TreeImages/Line_node.gif" ImgPath3 = "Lessons/TreeImages/iText.gif" End If IsEnd = False End If If Prefix = "" And i = 1 Then ImgPath = "Lessons/TreeImages/School.gif" '第一个节点使用特殊图标 If IsEnd Then '最后一个节点 ThisPrefix = Prefix & "<img height=16 width=16 src=""Lessons/TreeImages/Node_blank.gif"">" Else '非最后一个节点 ThisPrefix = Prefix & "<img height=16 width=16 src=""Lessons/TreeImages/Line_vertline.gif"">" End If If HasSubItem > 0 Then '有子节点 If Rs("B_Link") Then '有链接 Response.Write Prefix & "<span style=""cursor:hand;""><img src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><a href=""" & Rs("C_Link") & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></a></span><br>" Else '没有链接 Response.Write Prefix & "<span style=""cursor:hand;"" onclick=""clickItem(this);""><img src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></span><br>" End If Response.Write "<span style=""display:none;"">" Call WriteTree(Rs("I_RecordID"),ThisPrefix) '递归调用 Response.Write "</span>" Else '没有子节点 If Rs("B_Link") Then '有链接 Response.Write Prefix & "<span style=""cursor:hand;""><img height=16 src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><a href=""" & Rs("C_Link") & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></a></span><br>" Else '没有链接 Response.Write Prefix & "<span style=""cursor:hand;""><img height=16 src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></span><br>" End If End If Rs.MoveNext NextEnd Function%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE>TreeMenu Test</TITLE><base href="http://hyg:88/Test/treeproblem/"><META NAME="Generator" CONTENT="EditPlus"><script language="JavaScript">function clickItem(obj){ var srcobj = obj.nextSibling.nextSibling; if(srcobj.style.display == "none") { srcobj.style.display = ""; } else { srcobj.style.display = "none"; } if(obj.children[0].style.display == "none") { obj.children[0].style.display = ""; obj.children[1].style.display = "none"; } else { obj.children[0].style.display = "none"; obj.children[1].style.display = ""; }}</script></HEAD><BODY><%Call WriteTree(0,"")%></BODY></HTML> 脚本代码有点看不懂,求助各位大虾们! JS代码问题 高手解决 调试的时候说是 缺少对象 JSP查询数据很慢 |zyciis| javascript如何在子方法中停止父方法的进程 网页文件下载的js代码 按键小写变大写,在线等待,解决即给分,谢谢 如何在页面中判断上传文件是否重名?特急,在线等待. 如何取函数里参数的值? 如何连接数据库 请教高手!!(急急)通过javascript能够得到html中的页面的链接地址吗?在线苦等 在Javascript中有什么函数的功能等同于vbscript的Mid函数功能?本人对Mid函数功能也不了解!
<%
Function GetConn
'On Error Resume Next
'Dim Conn
'Set Conn = Server.CreateObject("ADODB.Connection")
'Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("teacher.MDB")
'Conn.Open
Set GetConn = Conn
End FunctionFunction WriteTree(ParentID,Prefix)
Dim Rs, ThisID, SQL, ImgPath, ImgPath2, ImgPath3, HasSubItem, IsEnd, ThisPrefix
Set Rs = Server.CreateObject("ADODB.RecordSet")
SQL = "Select * From tbl_Tree Where I_Rank=" & ParentID
Rs.Open SQL, GetConn, 1
For i = 1 To Rs.RecordCount
HasSubItem = GetConn.Execute("Select Count(*) From tbl_Tree Where I_Rank=" & Rs("I_RecordID"))(0)
If i = Rs.RecordCount Then '最后一个节点
If HasSubItem > 0 Then '有子节点
ImgPath = "Lessons/TreeImages/Line_plastnode.gif"
ImgPath2 = "Lessons/TreeImages/Line_mlastnode.gif"
ImgPath3 = "Lessons/TreeImages/OpenediDefFolder.gif"
Else '没有子节点
ImgPath = "Lessons/TreeImages/Line_lastnode.gif"
ImgPath2 = "Lessons/TreeImages/Line_lastnode.gif"
ImgPath3 = "Lessons/TreeImages/iText.gif"
End If
IsEnd = True
Else '非最后一个节点
If HasSubItem > 0 Then '有子节点
ImgPath = "Lessons/TreeImages/Line_pnode.gif"
ImgPath2 = "Lessons/TreeImages/Line_mnode.gif"
ImgPath3 = "Lessons/TreeImages/OpenediDefFolder.gif"
Else '没有子节点
ImgPath = "Lessons/TreeImages/Line_node.gif"
ImgPath2 = "Lessons/TreeImages/Line_node.gif"
ImgPath3 = "Lessons/TreeImages/iText.gif"
End If
IsEnd = False
End If
If Prefix = "" And i = 1 Then ImgPath = "Lessons/TreeImages/School.gif" '第一个节点使用特殊图标
If IsEnd Then '最后一个节点
ThisPrefix = Prefix & "<img height=16 width=16 src=""Lessons/TreeImages/Node_blank.gif"">"
Else '非最后一个节点
ThisPrefix = Prefix & "<img height=16 width=16 src=""Lessons/TreeImages/Line_vertline.gif"">"
End If
If HasSubItem > 0 Then '有子节点
If Rs("B_Link") Then '有链接
Response.Write Prefix & "<span style=""cursor:hand;""><img src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><a href=""" & Rs("C_Link") & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></a></span><br>"
Else '没有链接
Response.Write Prefix & "<span style=""cursor:hand;"" onclick=""clickItem(this);""><img src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></span><br>"
End If
Response.Write "<span style=""display:none;"">"
Call WriteTree(Rs("I_RecordID"),ThisPrefix) '递归调用
Response.Write "</span>"
Else '没有子节点
If Rs("B_Link") Then '有链接
Response.Write Prefix & "<span style=""cursor:hand;""><img height=16 src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><a href=""" & Rs("C_Link") & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></a></span><br>"
Else '没有链接
Response.Write Prefix & "<span style=""cursor:hand;""><img height=16 src=""" & ImgPath & """><img src=""" & ImgPath2 & """ style=""display:none""><img height=16 width=16 src=""" & ImgPath3 & """><span style=""border:#FFFFFF 1 solid;"" onmouseover=""this.style.backgroundColor='#DDDDDD';this.style.borderColor='#999999';"" onmouseout=""this.style.backgroundColor='';this.style.borderColor='#FFFFFF';"">" & Rs("C_Title") & "</span></span><br>"
End If
End If
Rs.MoveNext
Next
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>TreeMenu Test</TITLE>
<base href="http://hyg:88/Test/treeproblem/">
<META NAME="Generator" CONTENT="EditPlus">
<script language="JavaScript">
function clickItem(obj)
{
var srcobj = obj.nextSibling.nextSibling;
if(srcobj.style.display == "none")
{
srcobj.style.display = "";
}
else
{
srcobj.style.display = "none";
}
if(obj.children[0].style.display == "none")
{
obj.children[0].style.display = "";
obj.children[1].style.display = "none";
}
else
{
obj.children[0].style.display = "none";
obj.children[1].style.display = "";
}
}
</script>
</HEAD><BODY>
<%Call WriteTree(0,"")%>
</BODY>
</HTML>