一段生成treeview的js代码

转载 2006年05月30日 14:29:00
一段生成treeview的js代码
<html>
<head>
<title>ASP TreeView Exemple</title>
<meta name="author" content="Simon La Rochelle">
<meta name="description" content="This is an easy way to make a vb-like TreeView in ASP">

<script language='javascript'>

function ToggleDisplay(oButton, oItems) {

    if ((oItems.style.display == "") || (oItems.style.display == "none")) {
        oItems.style.display = "block";
        oButton.src = "http://www.chinaitpower.com/A/2004-09-06/minus.gif";
    }    else {
        oItems.style.display = "none";
        oButton.src = "http://www.chinaitpower.com/A/2004-09-06/plus.gif";
    }

    return false;

}

function HideDisplay(oItems) {

    oItems.style.display = "none";

}

function ShowDisplay(oItems) {

    oItems.style.display = "block";

}

</script>

</head>

<body bgcolor='#FFFFFF'>
<form action='TreeView.asp' method='post'>

<%

'HERE'S THE FIRST EXEMPLE (without checkboxes and links)
WriteHead "MyTreeView",1,"Exemple1",0,True,False,"",False
    WriteHead "MyTreeView",2,"Child1",1,True,False,"",False
        WriteHead "MyTreeView",3,"Child1-A",2,False,False,"",False
        WriteFoot
        WriteHead "MyTreeView",4,"Child1-B",2,False,False,"",False
        WriteFoot
        WriteHead "MyTreeView",5,"Child1-C",2,False,False,"",False
        WriteFoot
        WriteHead "MyTreeView",6,"Child1-D",2,False,False,"",False
        WriteFoot
    WriteFoot
    WriteHead "MyTreeView",7,"Child2",1,False,False,"",False
    WriteFoot
    WriteHead "MyTreeView",8,"Child3",1,False,False,"",False
    WriteFoot
    WriteHead "MyTreeView",9,"Child4",1,False,False,"",False
    WriteFoot
    WriteHead "MyTreeView",10,"Child5",1,False,False,"",False
    WriteFoot
WriteFoot

'Response.Write "<p>"

'HERE'S THE SECOND EXEMPLE (with checkboxes)
WriteHead "My2TreeView",1,"Exemple2",0,True,False,"",False
    WriteHead "My2TreeView",2,"Child1",1,True,False,"",False
        WriteHead "My2TreeView",3,"Child1-A",2,False,True,"",False
        WriteFoot
        WriteHead "My2TreeView",4,"Child1-B",2,False,True,"",False
        WriteFoot
        WriteHead "My2TreeView",5,"Child1-C",2,False,True,"",False
        WriteFoot
        WriteHead "My2TreeView",6,"Child1-D",2,False,True,"",False
        WriteFoot
    WriteFoot
    WriteHead "My2TreeView",7,"Child2",1,False,True,"",False
    WriteFoot
    WriteHead "My2TreeView",8,"Child3",1,False,True,"",False
    WriteFoot
    WriteHead "My2TreeView",9,"Child4",1,False,True,"",False
    WriteFoot
    WriteHead "My2TreeView",10,"Child5",1,False,True,"",False
    WriteFoot
WriteFoot

'Response.Write "<p>"

'HERE'S THE THIRD EXEMPLE (with links)
WriteHead "My3TreeView",1,"Development Sites",0,True,False,"",true
    WriteHead "My3TreeView",2,"Planet Source Code",1,True,False,"http://www.planetsourcecode.com",False
        WriteHead "My3TreeView",3,"Visual Basic",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.1/qx/vb/default.htm",False
        WriteFoot
        WriteHead "My3TreeView",4,"Java / Javascript",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.2/qx/vb/default.htm",False
        WriteFoot
        WriteHead "My3TreeView",5,"C / C++",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/default.htm",False
        WriteFoot
        WriteHead "My3TreeView",6,"ASP / VbScript",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.4/qx/vb/default.htm",False
        WriteFoot
        WriteHead "My3TreeView",7,"SQL",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.5/qx/vb/default.htm",False
        WriteFoot
        WriteHead "My3TreeView",8,"Perl",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.6/qx/vb/default.htm",False
        WriteFoot
        WriteHead "My3TreeView",9,"Delphi",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.7/qx/vb/default.htm",False
        WriteFoot
        WriteHead "My3TreeView",10,"PHP",2,False,False,"http://www.planetsourcecode.com/xq/ASP/lngWId.8/qx/vb/default.htm",False
        WriteFoot
    WriteFoot
    WriteHead "My3TreeView",11,"DevX",1,False,False,"http://www.devx.com",False
    WriteFoot
    WriteHead "My3TreeView",12,"MSDN",1,False,False,"http://msdn.microsoft.com",False
    WriteFoot
    WriteHead "My3TreeView",13,"4GuysFromRolla",1,False,False,"http://www.4guysfromrolla.com",False
    WriteFoot
    WriteHead "My3TreeView",14,"LearnASP",1,False,False,"http://www.learnasp.com",False
    WriteFoot
WriteFoot

%>

</form>
</body>
</html>

<%

'*********************************
'TREEVIEW SUBS
'*********************************

Sub WriteHead(TreeName,ItemID,ItemName,Level,IsParent,UseCheckBox,MyLink,IsOpn)

    Dim IsIE 'as boolean
    
    IsIE = (InStr(request.servervariables("HTTP_USER_AGENT"), "MSIE") > 0)

    'Spacing depends on what level you're at
    Select Case Level
        Case 1 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 2 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=36 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 3 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=72 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 4 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=108 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 5 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=144 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 6 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=180 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 7 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=216 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 8 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=252 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 9 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=288 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
        Case 10 : Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=324 HEIGHT=18 BORDER=0 ALT='><IMG SRC='http://www.chinaitpower.com/A/2004-09-06/dot1.gif' BORDER=0 ALT='>"
    End Select

    'If IsParent then put a plus sign else put a blank space
    If IsParent then
        'JsCode only if isIE
        If isIE then
            If IsOpn then
                Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/minus.gif' WIDTH=12 HEIGHT=10 ID='" & TreeName & ItemID & "Btn' ONCLICK='javascript:ToggleDisplay(" & TreeName & ItemID & "Btn, " & TreeName & ItemID & "chlds);' ALT BORDER='0'>"
            Else
                Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/plus.gif' WIDTH=12 HEIGHT=10 ID='" & TreeName & ItemID & "Btn' ONCLICK='javascript:ToggleDisplay(" & TreeName & ItemID & "Btn, " & TreeName & ItemID & "chlds);' ALT BORDER='0'>"
            End If
        Else
            If IsOpn then
                Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/minus.gif' WIDTH=12 HEIGHT=10 ID='" & TreeName & ItemID & "Btn' ALT BORDER='0'>"
            Else
                Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/plus.gif' WIDTH=12 HEIGHT=10 ID='" & TreeName & ItemID & "Btn' ALT BORDER='0'>"
            End if
        End If    
    Else
        If Level = 0 then
            Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/nosign2.gif' WIDTH=12 HEIGHT=10 ALT BORDER='0'>"
        Else
            Response.Write "<IMG SRC='http://www.chinaitpower.com/A/2004-09-06/nosign.gif' WIDTH=12 HEIGHT=10 ALT BORDER='0'>"
        End If
    End if
    
    'If UseCheckBox then show a checkbox else add space
    If UseCheckBox then
        Response.Write "<INPUT TYPE='checkbox' NAME='" & TreeName &"chk' VALUE='" & ItemID & "'>"
    Else
        Response.Write "<img src='http://www.chinaitpower.com/A/2004-09-06/t_dot.gif' WIDTH=4 HEIGHT=18 BORDER=0 ALT='>"
    End If
        
    Response.Write "<font face='Verdana,Arial,Helvetica' size='2' color='#333399'>"
    
    'If MyLink = "" then do not use link
    If MyLink = "" then
        'If first Level, use bold
        If Level = 0 then Response.Write "<b>" & ItemName & "</b>" else Response.Write ItemName
    Else
        'If first Level, use bold
        If Level = 0 then Response.Write "<b><a href='" & MyLink & "'><font color='#333399'>" & ItemName & "</a></b>" else Response.Write "<a href='" & MyLink & "'><font color='#333399'>" & ItemName & "</a>"
    End If

    Response.Write "</font>"
    Response.Write "<br>"
    
    'Always add DIV because WriteFoot() will close it
    Response.Write "<div ID='" & TreeName & ItemID & "chlds'>"
    
    'JsCode only if IsIE and if the section is not open
    If IsIE then
        If IsOpn then
            Response.Write "<script language='javascript'>ShowDisplay(" & TreeName & ItemID & "chlds);</script>"
        Else
            Response.Write "<script language='javascript'>HideDisplay(" & TreeName & ItemID & "chlds);</script>"
        End If
    End If

End Sub

Sub WriteFoot()

    Response.Write "</div>"

End Sub

%>

一段用VB生成GUID的代码

  • 2011年06月29日 15:52
  • 2KB
  • 下载

由一段代码谈前端js优化和编码规范

这段代码是撸主刚毕业那会写的,主要是实现一个左侧的导航条的折叠功能。当时实现的比较简陋,每次在导航条增加新的项目的时候,都要手动去修改js代码中写死的索引。。。确实是比较恼火的,后来就修改了一下,能够...

分享一段JS代码,个人感觉很使用:网页浏览历史记录

小林网 - Xiaolin.Net 您最近浏览过的新闻 未找到您的最近浏览记录 // if(navigator.cookieEnabled){//判断是否支持Cooki...
  • liuzx32
  • liuzx32
  • 2012年07月10日 21:21
  • 963

js构造函数原型(prototype)问题分析(一段烂代码引发的博客)

Email:longsu2010 at yeah dot net 很久以前有人发了我如下的代码, 问我有什么问题。今天旧话重提,我索性就写一篇博客分享给大家。事先声明,本博只分析问题,并不提供解决方案...
  • tt361
  • tt361
  • 2013年04月09日 10:54
  • 1803

分享一段JS代码,个人感觉很使用:网页浏览历史记录

将一段JS代码封装成一个方法

}).mouseout(function(){ $("#plate-3hover").removeClass("plate-3after") }); $("#plate-4").mousee...

从网上找到的一段定时向上滚动文字的JS代码 和大家分享

从网上找到的一段定时向上滚动文字的JS代码 和大家分享首先要感谢这段JS代码的作者,给我带来很大的方便代码如下:...

由一段代码谈前端js优化和编码规范(一)

1.在函数内部使用$li_elem,wolfArray这样的全局变量,其实这完全是没有必要的; 2.在判断是否含有style标签的时候,我仍然适用的是$li_elem对象,其实我这里只要把wolfAr...

我用JS写的一段创建TABLE,添加行,模糊匹配,根据CHECKBOX删除内容,创建标题的代码(删除完再添加行有计数器的BUG)

做错了,贴出来,需要用JQUERY做,现在完全整成DOM和JS做的了 效果图: 代码: $(document).ready(function() { $("p").click...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:一段生成treeview的js代码
举报原因:
原因补充:

(最多只允许输入30个字)