要求:子节点全选中,父节点全选中,否则不洗;当然父节点选中下面的子节点全选中。
取值要求:如果下面的子节点全选中,那么我们只选父节点值。否则只选子节点的值。
取值要求:如果下面的子节点全选中,那么我们只选父节点值。否则只选子节点的值。
解决方案 »
- window.location在firefox火狐下面为什么不执行啊?
- 如何计算每一行的值?谢谢大家.马上解决,马上结帐
- 如何将字符串数组传递到javascript中
- 请问是否可以在html页面中把网页中的表格内容导入到word中,我现在可以导入到excel,但不知道怎样导入到word中,请指教!
- 不用弹出窗口,怎么关闭ie的工具栏、地址栏、菜单等?
- 关于正则表达式一问 急
- 一个简单的问题,请帮忙!
- 如何使用SQL2000实现利用XMLHTTP无刷新添加数据???
- 大虾看看这个程式有什么错误呀?调了半天啦!!
- 这样关窗口为什么说没有权限?在本机就可以,上传上去就不行了
- JS替换flash,请求支援
- IE9 不能显示本地图片问题
几个常用的tree:
Ext的TreePanel
easy ui 的tree
TreeView
这些框架 也都需要我们自己去修改 楼主如果js还可以的话 可以去试试
各种花样 。
<input type="checkbox" name="parent" onclick="judge()"/>我是好父亲<br/><br/><input type="checkbox" name="son" onclick="judgeSelectAll()"/>我是大儿子<br/>
<input type="checkbox" name="son" onclick="judgeSelectAll()"/>我是二儿子<br/>
<input type="checkbox" name="son" onclick="judgeSelectAll()"/>我是小儿子<br/>
<input type="button" value="测试一下" onclick="out()"/><script>
var isParentChecked = false;
function judge(){
var sons = document.getElementsByName('son');
if(!isParentChecked){
SelectAll(true);
isParentChecked = true;
}else{
SelectAll(false);
isParentChecked = false;
}
}
function judgeSelectAll(){
var sons = document.getElementsByName('son');
var parent = document.getElementsByName('parent')[0];
isParentChecked = true;
parent.checked = true;
for(var i=0;i<sons.length;i++){
if(!sons[i].checked){
isParentChecked = false;
parent.checked = false;
}
}
}
function SelectAll(flag){
var sons = document.getElementsByName('son');
for(var i=0;i<sons.length;i++){
sons[i].checked = flag;
}
}
//这里你就可以编写自己需要的代码了
function out(){
if(isParentChecked){
alert('传出父节点的值');
}else{
alert('传出子节点的值');
}
}
</script>
不明白的加我QQ把你弄明白为止
zTree
this.leaf = leaf; 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;};// Tree objectfunction dTree(objName,rootid,img) { this.config = { target : null,
linksAttr :null, folderLinks : true, useSelection : true, useCookies : false, useLines : true, useIcons : true, useStatusText : true, closeSameLevel : true,
closeSameLevel : true,
checkbox :false,
radiobox :true,
allnode :true,
newLine :10,
inOrder : false } this.icon = {
point :img+'/images/treeImg/point.gif', root : img+'/images/treeImg/base.gif', folder : img+'/images/treeImg/folder.gif', folderOpen : img+'/images/treeImg/folderopen.gif', node : img+'/images/treeImg/page.gif', empty : img+'/images/treeImg/empty.gif', line : img+'/images/treeImg/line.gif', join : img+'/images/treeImg/join.gif', joinBottom : img+'/images/treeImg/joinbottom.gif', plus : img+'/images/treeImg/plus.gif', plusBottom : img+'/images/treeImg/plusbottom.gif', minus : img+'/images/treeImg/minus.gif', minusBottom : img+'/images/treeImg/minusbottom.gif',
enter : img+'/images/treeImg/enter.gif',
enterDown : img+'/images/treeImg/enterDown.gif', nlPlus : img+'/images/treeImg/enter.gif', nlMinus : img+'/images/treeImg/enterDown.gif' }; this.obj = objName; this.aNodes = []; this.aIndent = []; this.root = new Node(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false;
this.rootid=rootid;};
//textarea.value=str;
return str;};// Creates the tree structuredTree.prototype.addNode = function(pNode) { var str = ''; var n=0; if (this.config.inOrder) n = pNode._ai; for (n; n<this.aNodes.length; n++) { if (this.aNodes[n].pid == pNode.id) { var cn = this.aNodes[n]; cn._p = pNode; cn._ai = n;
this.setCS(cn); if (!cn.target && this.config.target) cn.target = this.config.target; if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id); if (!this.config.folderLinks && cn._hc) cn.url = null; if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) { cn._is = true; this.selectedNode = n; this.selectedFound = true; } str += this.node(cn, n); if (cn._ls) break; } } return str;};
var str='<tr><td>';
str += '<table cellpadding=0 cellspacing=0 border=0 class="dTreeNode"> <tr><td valign="top">' + this.indent(node, nodeId);
str +='</td><td><table cellpadding=0 cellspacing=0 border=0 ><tr><td>';
if(this.config.checkbox)
str+=' <input type="checkbox" name="chkbox" value="'+node.id+'" id="c'+ this.obj + nodeId + '" onclick="javascript:'+this.obj+'.selectNodes('+nodeId+')"> ';
if(this.config.radiobox&&!node._hc)
str+=' <input type="radio" name="radiobox" value="'+node.id+'" id="c'+ this.obj + nodeId + '" onclick="javascript:'+this.obj+'.selectNodes('+nodeId+')"> '; if (this.config.useIcons) { if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node); if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node; if (this.root.id == node.pid) { node.icon = this.icon.root; node.iconOpen = this.icon.root; } str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />'; }
if (node.url) {
//alert(node.url);
//str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + this.config.linksAttr+'&root_id='+this.rootid+'&node_id='+node.id+'"';
str += '<span onfocus="blur()" id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '"';
if (node.title) str += ' title="' + node.title + '"'; if (node.target) str += ' target="' + node.target + '"'; if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" '; if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc)) str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"'; str += '>'; }