用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧Delphi

我写的一段递归生成类似Windows资源管理器一样效果的树状菜单的代码,请指正

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 20:17:42
<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.newasp.net/images/NullPic.gif";
  }

else
  {ss.style.display="none";
   aa.style.display="none";
   ii.src=http://www.newasp.net/images/NullPic.gif";}
}

function onlyclose(ss,ii,aa)
{
   ss.style.display="none";
   aa.style.display="none";
   ii.src=http://www.newasp.net/images/NullPic.gif";
}
</SCRIPT>
</HEAD>
<BODY bgColor=#99CCFF>
<%
    dim dbConn
    dim IDIndex
    
    IDIndex = 0
    
    ''建立数据库连接
    Set dbConn = Server.CreateObject("Adodb.Connection")
    dbConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("test.mdb")
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''生成文件类型树的递归函数,传入参数:NowItem为树节点的ID   ''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Sub DoItem(NowItem)
        dim rsTest
        dim YoungerBrother    ''下一个兄弟节点的ID
        dim OlderSon        ''第一个字节点的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") & "")
        
        ''显示子节点
        if OlderSon = "" or OlderSon = "00" then    ''当此项无子项时,输出相应的代码
            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.显示本项内容
            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.newasp.net/images/NullPic.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>

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:6,218.75000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号