http://uheart.myetang.com/treeproblem.rar为完整的文件包,里有数据库,IIS直接运行里面的页面文件就行了

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2547/2547265.xml?temp=.9461634
      

  2.   

    <!-- #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 = 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>