明輝手游網(wǎng)中心:是一個免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

我寫的一段遞歸生成類似Windows資源管理器一樣效果的樹狀菜單的代碼,請指正

[摘要]<HTML><HEAD><META content="text/html; charset=gb2312" http-equiv=Content-Type><SCRIPT lanuage="JScript">f...

<HTML>
<HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<SCRIPT lanuage="JScript">
function turnit(ss,ii,aa)
{

if (ss.style.display=="none")
  {ss.style.display="";
   aa.style.display="";
   ii.src="http://www.okasp.com/techinfo/minus.gif";
  }

else
  {ss.style.display="none";
   aa.style.display="none";
   ii.src="http://www.okasp.com/techinfo/http://www.okasp.com/techinfo/plus.gif";}
}

function onlyclose(ss,ii,aa)
{
   ss.style.display="none";
   aa.style.display="none";
   ii.src="http://www.okasp.com/techinfo/http://www.okasp.com/techinfo/plus.gif";
}
</SCRIPT>
</HEAD>
<BODY bgColor=#99CCFF>
<%
    dim dbConn
    dim IDIndex
    
    IDIndex = 0
    
    '建立數(shù)據(jù)庫連接
    Set dbConn = Server.CreateObject("Adodb.Connection")
    dbConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("test.mdb")
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''生成文件類型樹的遞歸函數(shù),傳入?yún)?shù):NowItem為樹節(jié)點(diǎn)的ID   ''
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Sub DoItem(NowItem)
        dim rsTest
        dim YoungerBrother    '下一個兄弟節(jié)點(diǎn)的ID
        dim OlderSon        '第一個字節(jié)點(diǎn)的ID
        
        '建立記錄集
        set rsTest = Server.CreateObject("Adodb.recordset")
    
        '生成sql語句,操作Doc_TypeTree表
        strSql = "select * from tab_test where ID = '" & NowItem & "'"
    
        '生成記錄集
        rsTest.open strSql,dbConn,1,3
        
        if rsTest.eof then
            rsTest.close
            set recDosType = nothing
            exit sub
        end if
        
        YoungerBrother = trim(rsTest("BrotherNode") & "")
        OlderSon = trim(rsTest("SonNode") & "")
        NodeID = trim(rsTest("ID") & "")
        NodeName = trim(rsTest("NodeName") & "")
        
        '顯示子節(jié)點(diǎn)
        if OlderSon = "" or OlderSon = "00" then    '當(dāng)此項(xiàng)無子項(xiàng)時,輸出相應(yīng)的代碼
            response.write "<TR>" & chr(10)
            response.write "<TD> </TD>" & chr(10)
            response.write "<TD>"
              response.write "<A href='test'>" & NodeName & "</A>"              
                response.write "</TD>" & chr(10)
            response.write "</TR>" & chr(10)        
        else        
            '*1.顯示本項(xiàng)內(nèi)容
            response.write "<TR>" & chr(10)
            response.write "<TD language=JScript onmouseup=turnit(" & _
                        "Content" & IDIndex & "," & _
                        "img" & IDIndex & "," & _
                        "Aux" & IDIndex & ");>" & chr(10)            
              response.write "<IMG height=9 id=img" & IDIndex & " src='http://www.okasp.com/techinfo/http://www.okasp.com/techinfo/plus.gif' width=9>" & chr(10)
                response.write "</TD>" & chr(10)
            response.write "<TD>" & chr(10)
              response.write "<A href='Frame_4_publish.asp?DocTypeID=" & _
                          NodeID & "' target='frmFour'>" & NodeName & _
                          "</A>" & chr(10)
                response.write "</TD>" & chr(10)
            response.write "</TR>" & chr(10)
            
            '*2.輸出子孫樹頭代碼
            response.write "<TR>" & chr(10)
            response.write "<TD id=Aux" & IDIndex & " style='display: none'> </TD>" & chr(10)
            response.write "<TD id=Content" & IDIndex & " style='display: none'>" & chr(10)
            response.write "<TABLE border='0'>"
            IDIndex = IDIndex + 1
        
            '*3.輸出子孫樹代碼
            call    DoItem(OlderSon)
            
            '*4.輸出子孫樹尾代碼
            response.write "</TABLE>"
            response.write "</TD>" & chr(10)
            response.write "</TR>" & chr(10)
        end if
        
        if YoungerBrother <> "" and YoungerBrother <> "00" then
            call DoItem(YoungerBrother)
        end if        
                
        rsTest.close
        set rsTest = nothing
    end Sub
    
    response.write "<table border='0'>"
    call DoItem("01")
    response.write "</table>"
    
    dbConn.close
    set dbConn = nothing
%>
</BODY>
</HTML>