做个例子给你看看:
http://www.nethood.net/tree.asp
是这样的吗?

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>结构</title>
    <script language=javascript>
    function showhiden(self_obj,obj)
    {
    var img_src=self_obj.src;
    if(img_src.indexOf('open.gif')>-1)
    {
    obj.style.display='none';
    self_obj.src='images/close.gif'
    }
    if(img_src.indexOf('open_end.gif')>-1)
    {
    obj.style.display='none';
    self_obj.src='images/close_end.gif'
    }
    if(img_src.indexOf('close.gif')>-1)
    {
    obj.style.display='block';
    self_obj.src='images/open.gif'
    }
    if(img_src.indexOf('close_end.gif')>-1)
    {
    obj.style.display='block';
    self_obj.src='images/open_end.gif'
    }
    }
    </script>
    </head><body leftmargin="10" topmargin="10" rightmargin="10" bottommargin="10" style="border-style: solid; border-width: 0">
    <%
    dim table_num
    table_num=0
    function charsize(char)
    if(asc(char)<0) then 
    charsize=2
    else
    charsize=1
          end if
        end function
        function str_size(str)
         dim i
         if len(str)=0 then
         str_size=0
         else
         for i=1 to len(str)
    str_size=str_size+charsize(mid(str,i,1))
    next
    end if
    end function
    sub get_tree(attach)
    dim cmd,db,name,sort,size,the_end
    set cmd=server.createobject("adodb.connection")
    set db=server.createobject("adodb.recordset")
    cmd.connectionstring="DRIVER=SQL Server;SERVER=自己改;DATABASE=自己改;UID=自己改;PWD=自己改;"
    cmd.open
    set db=cmd.Execute("select id,name,sort from tree where attach =" & attach & " order by sort desc,create_date desc")
    the_end=false
    if db.eof then
    response.write "<table border='0' cellspacing='0' cellpadding='0'><tr><td><img border='0' src='images/file_end.gif' align='absbottom' height='20'>&nbsp(空)</td></tr></table>"
    end if
    do while not db.eof
    id=db("id")
    name=db("name")
    sort=db("sort")
    size=str_size(name)*8+38
    db.movenext
    if db.eof then
    the_end=true
    end if
    if sort then
    response.write "<table border='0' width='" & size & "' cellspacing='0' cellpadding='0'><tr><td>"
    if the_end then
    response.write "<img border='0' src='images/close_end.gif' align='absbottom' onclick='showhiden(this,t" & table_num & ")' height='20'>"
    else
    response.write "<img border='0' src='images/close.gif' align='absbottom' onclick='showhiden(this,t" & table_num & ")' height='20'>"
    end if
    response.write "&nbsp" & name & "</td></tr></table>"
    response.write "<table border='0' cellspacing='0' cellpadding='0' id='t" & table_num & "' style='display:none'><tr>"
    if the_end then
    response.write "<td width='18' style='font-size:8pt'>"
    else
    response.write "<td background='images/space.gif' width='18' style='font-size:8pt'>"
    end if
    response.write "&nbsp&nbsp&nbsp</td><td>"
    table_num=table_num+1
    get_tree(id)
    response.write "</td></tr></table>"
    else
    response.write "<table border='0' width='" & size & "' cellspacing='0' cellpadding='0'><tr><td>"
    if the_end then
    response.write "<img border='0' src='images/file_end.gif' align='absbottom' height='20'>"
    else
    response.write "<img border='0' src='images/file.gif' align='absbottom' height='20'>"
    end if
    response.write "&nbsp" & name & "</td></tr></table>"
    end if
    loop
    cmd.close
    set cmd=nothing
    set db=nothing
    set name=nothing
    set arrach=nothing
    set sort=nothing
    set the_end=nothing
    end sub
    get_tree(0)
    %>
    </body></html>
    库结构可根据程序定。