我的程序如下:
Dim strUserID'用户ID号
Dim rs3,sql3
Dim strCheckedStringTemp
if request("strUserID")<>"" then
'strCheckedStringTemp = VSMMS.GetPartStr("HR_Staff","Right_Str","ID",request("strUserID"),"4")
if strCheckedStringTemp<>"" then
strCheckedStringTemp = ","&strCheckedStringTemp&","
else
strCheckedStringTemp = ""
end if
elseif request("strRoleID")<>"" then
RightStringTemp = GetTableValue("tblUserRole","Auth_ID","Role_ID",request("strRoleID"))
response.write RightStringTemp
if RightStringTemp<>"" then
RightStringTemp = ","&RightStringTemp&","
else
RightStringTemp = ""
end if
end if
%>
<html>
<head>
<title>CNL Tree Menu Ver1.02 - 无限级树形菜单 Written by CNLei, 枫岩 </title>
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<link type="text/css" rel="stylesheet" href="../css/treemenu.css" />
<script type="text/javascript" src="../js/treemenu.js"></script>
</head>
<body>
<%
set rshigher=server.CreateObject("Adodb.recordset")
sql="select * from tblUserAuth where Parent_ID='0'"
rshigher.open sql,oConn,1,1
higherNum=rshigher.recordcount '获取一级菜单数量
%>
<!--CNLTreeMenu Start:-->
<div class="CNLTreeMenu" id="CNLTreeMenu1">
<p><a id="AllOpen_1" href="#" onclick="MyCNLTreeMenu1.SetNodes(0);Hd(this);Sw('AllClose_1');">全部展开</a><a id="AllClose_1" href="#" onclick="MyCNLTreeMenu1.SetNodes(1);Hd(this);Sw('AllOpen_1');" style="display:none;">全部折叠</a></p>
<ul>
<%
for i=0 to higherNum-1
set rssub=server.CreateObject("Adodb.recordset")
sql="select * from tblUserAuth where Parent_ID='"&rshigher("Author_ID")&"' and disp='0'"
rssub.open sql,oConn,1,1
subNum=rssub.recordcount '获取子菜单数量
%>
<li class="Opened"><input type="checkbox" name="chkRight" value="<%=rshigher("ID")%>"><%=rshigher("Authority")%>
<ul>
<%for j=0 to subNum-1%>
<li class="Child"><input type="checkbox" name="chksub" value="<%=rssub("ID")%>"><%=rssub("Authority")%>
</li><!--Sub Node 2-->
<%
rssub.movenext
next
%>
</ul>
</li><!--Sub Node 1 -->
<%
rshigher.movenext
next
%>
</ul>
</div><!-- CNLTreeMenu -->
<!--CNLTreeMenu1 End!-->
<script type="text/javascript">
<!--
var MyCNLTreeMenu1=new CNLTreeMenu("CNLTreeMenu1","li");
MyCNLTreeMenu1.InitCss("Opened","Closed","Child","../images/s.gif");-->
</script>treemenu.js:
function Ob(o){
var o=document.getElementById(o)?document.getElementById(o):o;
return o;
}
function Hd(o) {
Ob(o).style.display="none";
}
function Sw(o) {
Ob(o).style.display="";
}
function ExCls(o,a,b,n){
var o=Ob(o);
for(i=0;i<n;i++) {o=o.parentNode;}
o.className=o.className==a?b:a;
}
function CNLTreeMenu(id,TagName0) {
this.id=id;
this.TagName0=TagName0==""?"li":TagName0;
this.AllNodes = Ob(this.id).getElementsByTagName(TagName0);
this.InitCss = function (ClassName0,ClassName1,ClassName2,ImgUrl) {
this.ClassName0=ClassName0;
this.ClassName1=ClassName1;
this.ClassName2=ClassName2;
this.ImgUrl=ImgUrl || "../images/s.gif";
this.ImgBlankA ="<img src=\""+this.ImgUrl+"\" class=\"s\" onclick=\"ExCls(this,'"+ClassName0+"','"+ClassName1+"',1);\" alt=\"展开/折叠\" />";
this.ImgBlankB ="<img src=\""+this.ImgUrl+"\" class=\"s\" />";
for (i=0;i<this.AllNodes.length;i++ ) {
this.AllNodes[i].className==""?this.AllNodes[i].className=ClassName1:"";
this.AllNodes[i].innerHTML=(this.AllNodes[i].className==ClassName2?this.ImgBlankB:this.ImgBlankA)+this.AllNodes[i].innerHTML;
}
}
this.SetNodes = function (n) {
var sClsName=n==0?this.ClassName0:this.ClassName1;
for (i=0;i<this.AllNodes.length;i++ ) {
this.AllNodes[i].className==this.ClassName2?"":this.AllNodes[i].className=sClsName;
}
}
}我只能完成展开和收缩树,在节点前加复选框,但是不能完成点选子节点和父节点的联动,并且节点的id值传不了,怎么办,请朋友们帮帮忙。
Dim strUserID'用户ID号
Dim rs3,sql3
Dim strCheckedStringTemp
if request("strUserID")<>"" then
'strCheckedStringTemp = VSMMS.GetPartStr("HR_Staff","Right_Str","ID",request("strUserID"),"4")
if strCheckedStringTemp<>"" then
strCheckedStringTemp = ","&strCheckedStringTemp&","
else
strCheckedStringTemp = ""
end if
elseif request("strRoleID")<>"" then
RightStringTemp = GetTableValue("tblUserRole","Auth_ID","Role_ID",request("strRoleID"))
response.write RightStringTemp
if RightStringTemp<>"" then
RightStringTemp = ","&RightStringTemp&","
else
RightStringTemp = ""
end if
end if
%>
<html>
<head>
<title>CNL Tree Menu Ver1.02 - 无限级树形菜单 Written by CNLei, 枫岩 </title>
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<link type="text/css" rel="stylesheet" href="../css/treemenu.css" />
<script type="text/javascript" src="../js/treemenu.js"></script>
</head>
<body>
<%
set rshigher=server.CreateObject("Adodb.recordset")
sql="select * from tblUserAuth where Parent_ID='0'"
rshigher.open sql,oConn,1,1
higherNum=rshigher.recordcount '获取一级菜单数量
%>
<!--CNLTreeMenu Start:-->
<div class="CNLTreeMenu" id="CNLTreeMenu1">
<p><a id="AllOpen_1" href="#" onclick="MyCNLTreeMenu1.SetNodes(0);Hd(this);Sw('AllClose_1');">全部展开</a><a id="AllClose_1" href="#" onclick="MyCNLTreeMenu1.SetNodes(1);Hd(this);Sw('AllOpen_1');" style="display:none;">全部折叠</a></p>
<ul>
<%
for i=0 to higherNum-1
set rssub=server.CreateObject("Adodb.recordset")
sql="select * from tblUserAuth where Parent_ID='"&rshigher("Author_ID")&"' and disp='0'"
rssub.open sql,oConn,1,1
subNum=rssub.recordcount '获取子菜单数量
%>
<li class="Opened"><input type="checkbox" name="chkRight" value="<%=rshigher("ID")%>"><%=rshigher("Authority")%>
<ul>
<%for j=0 to subNum-1%>
<li class="Child"><input type="checkbox" name="chksub" value="<%=rssub("ID")%>"><%=rssub("Authority")%>
</li><!--Sub Node 2-->
<%
rssub.movenext
next
%>
</ul>
</li><!--Sub Node 1 -->
<%
rshigher.movenext
next
%>
</ul>
</div><!-- CNLTreeMenu -->
<!--CNLTreeMenu1 End!-->
<script type="text/javascript">
<!--
var MyCNLTreeMenu1=new CNLTreeMenu("CNLTreeMenu1","li");
MyCNLTreeMenu1.InitCss("Opened","Closed","Child","../images/s.gif");-->
</script>treemenu.js:
function Ob(o){
var o=document.getElementById(o)?document.getElementById(o):o;
return o;
}
function Hd(o) {
Ob(o).style.display="none";
}
function Sw(o) {
Ob(o).style.display="";
}
function ExCls(o,a,b,n){
var o=Ob(o);
for(i=0;i<n;i++) {o=o.parentNode;}
o.className=o.className==a?b:a;
}
function CNLTreeMenu(id,TagName0) {
this.id=id;
this.TagName0=TagName0==""?"li":TagName0;
this.AllNodes = Ob(this.id).getElementsByTagName(TagName0);
this.InitCss = function (ClassName0,ClassName1,ClassName2,ImgUrl) {
this.ClassName0=ClassName0;
this.ClassName1=ClassName1;
this.ClassName2=ClassName2;
this.ImgUrl=ImgUrl || "../images/s.gif";
this.ImgBlankA ="<img src=\""+this.ImgUrl+"\" class=\"s\" onclick=\"ExCls(this,'"+ClassName0+"','"+ClassName1+"',1);\" alt=\"展开/折叠\" />";
this.ImgBlankB ="<img src=\""+this.ImgUrl+"\" class=\"s\" />";
for (i=0;i<this.AllNodes.length;i++ ) {
this.AllNodes[i].className==""?this.AllNodes[i].className=ClassName1:"";
this.AllNodes[i].innerHTML=(this.AllNodes[i].className==ClassName2?this.ImgBlankB:this.ImgBlankA)+this.AllNodes[i].innerHTML;
}
}
this.SetNodes = function (n) {
var sClsName=n==0?this.ClassName0:this.ClassName1;
for (i=0;i<this.AllNodes.length;i++ ) {
this.AllNodes[i].className==this.ClassName2?"":this.AllNodes[i].className=sClsName;
}
}
}我只能完成展开和收缩树,在节点前加复选框,但是不能完成点选子节点和父节点的联动,并且节点的id值传不了,怎么办,请朋友们帮帮忙。
initializeCheckBox: function(clientId) {
var container = $(clientId);
if (container) {
var setCheckboxOnclickEvent = function(nodes) {
if (aloe.isUndefined(nodes)) return; var node, cbx; for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
aloe.aspNet.treeView.associateCheckBox(node)
node.checkBox.onclick = function() {
// 递归 选中/清除 全部子节点。
aloe.aspNet.treeView.setCheckBox(this.treeNode, this.checked); if (this.checked) {
// 递归选中直接父节点。
aloe.aspNet.treeView.selectParentTreeNode(this.treeNode);
} else {
// 递归检查,直接父节点若无选中子节点则清除,否则保持选中。
aloe.aspNet.treeView.unselectParentTreeNode(this.treeNode);
}
}; setCheckboxOnclickEvent(aloe.aspNet.treeView.getChildTreeNodes(node));
}
}
// 深度为 0 的子节点。
setCheckboxOnclickEvent(document.getChildElementsByTagName(container, "table"));
}
else
aloe.debug(String.format("当前页面不存在 Id 为 {0} 的 TreeView 控件!"), "aloe.aspNet.treeView.initializeCheckBox");
}