六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 95|回复: 0

checkbox权限树

[复制链接]

升级  29.33%

22

主题

22

主题

22

主题

秀才

Rank: 2

积分
94
 楼主| 发表于 2013-2-7 19:55:54 | 显示全部楼层 |阅读模式
checkbox权限树
          
    html代码  
<html><head><title>dtree</title><link rel="StyleSheet" href="dtree.css" type="text/css" /><script type="text/javascript" src="dtree.js"></script></head><body><div class="dtree"><p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p><script type="text/javascript"><!--d = new dTree('d');d.add(0,-1,'菜单权限树');d.add(1,0,'authority','25','一级菜单1 ');d.add(2,1,'authority','26','二级菜单1 ');d.add(3,2,'authority','27','三级菜单1 ');d.add(4,2,'authority','28','三级菜单2 ');d.add(32,3,'authority','26','二级菜单1 ');d.add(33,32,'authority','27','用户管理 ');d.add(34,32,'authority','28','用户组管理 ');d.add(22,1,'authority','26','二级菜单1 ');d.add(23,22,'authority','27','用户管理 ');d.add(24,22,'authority','28','用户组管理 ');d.add(6,0,'authority','25','一级菜单2 ',true,true);d.add(7,6,'authority','26','二级菜单2 ',true,true);d.add(8,7,'authority','27','用户管理 ',true,true);d.add(9,7,'authority','28','用户组管理 ',true,true);d.add(11,0,'authority','25','一级菜单3 ');d.add(12,11,'authority','26','二级菜单3 ');d.add(13,12,'authority','27','用户管理 ');d.add(14,12,'authority','27','用户组管理 ');document.write(d);d.openAll();//--></script></div><div><input type='button' name='bTest' value='test' onclick='test();'></div></body><script type="text/javascript"><!--function test(){var count = 0;var obj = document.all.authority;for(i=0;i<obj.length;i++){if(obj[i].checked){alert(obj[i].value);count ++;}}}//--></script></html>   
    dtree.js 关键代码
                                     Node这个方法 里解释了 各个参数的含义
function Node(id, pid, cname, cvalue, cshow, cchecked, cdisabled, url, title, target, icon, iconOpen, open) {this.id = id;this.pid = pid;//chechbox的名称this.cname = cname;//chechbox的值this.cvalue = cvalue;//chechbox的显示this.cshow = cshow;//chechbox是否被选中,默认是不选this.cchecked = cchecked||false;//chechbox是否可用,默认是可用this.cdisabled = cdisabled||false;//节点链接,默认是虚链接this.url = url||'#';this.title = title;this.target = target;this.icon = icon;this.iconOpen = iconOpen;this._io = open || false;this._is = false;this._ls = false;this._hc = false;this._ai = 0;this._p;}; 
   具体的使用可以下载附件查看代码.......反正挺简单的....
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表