问题描述
AAAAABBBBBCCCCC这种结构的,点A下面的A全部选中,点B下面的B全部选中....反之,全不选;
解决方案
解决方案二:
<headrunat="server"><title>无标题页</title><scripttype="text/javascript">functionclient_OnTreeNodeChecked(){varobj=window.event.srcElement;vartreeNodeFound=false;varcheckedState;if(obj.tagName=="INPUT"&&obj.type=="checkbox"){vartreeNode=obj;checkedState=treeNode.checked;do{obj=obj.parentElement;}while(obj.tagName!="TABLE")varparentTreeLevel=obj.rows[0].cells.length;varparentTreeNode=obj.rows[0].cells[0];vartables=obj.parentElement.getElementsByTagName("TABLE");varnumTables=tables.lengthif(numTables>=1){for(i=0;i<numTables;i++){if(tables[i]==obj){treeNodeFound=true;i++;if(i==numTables){return;}}if(treeNodeFound==true){varchildTreeLevel=tables[i].rows[0].cells.length;if(childTreeLevel>parentTreeLevel){varcell=tables[i].rows[0].cells[childTreeLevel-1];varinputs=cell.getElementsByTagName("INPUT");inputs[0].checked=checkedState;}else{return;}}}}}}</script></head><body><formid="form1"runat="server"><div><asp:TreeViewID="TreeView1"runat="server"onclick="client_OnTreeNodeChecked()"ShowCheckBoxes="All"><Nodes><asp:TreeNodeText="A"Value="A"><asp:TreeNodeText="AA"Value="AA"></asp:TreeNode><asp:TreeNodeText="AAA"Value="AAA"></asp:TreeNode></asp:TreeNode><asp:TreeNodeText="B"Value="B"><asp:TreeNodeText="BB"Value="BB"></asp:TreeNode><asp:TreeNodeText="BBB"Value="BBB"></asp:TreeNode></asp:TreeNode></Nodes></asp:TreeView></div></form></body>
解决方案三:
有种方式叫遍历,还有种方式叫循环
解决方案四:
1,分析html结构2,写脚本-------------------<p><inputonclick='MultiCheck(this)'type="checkbox"/></p><div><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/></div><p><inputonclick='MultiCheck(this)'type="checkbox"/></p><div><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/></div><p><inputonclick='MultiCheck(this)'type="checkbox"/></p><div><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/></div><p><inputonclick='MultiCheck(this)'type="checkbox"/></p><div><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/></div><p><inputonclick='MultiCheck(this)'type="checkbox"/></p><div><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/><inputtype="checkbox"/></div><script>functionMultiCheck(o){varcbks=o.parentNode.nextSibling.getElementsByTagName("input");for(i=0;i<cbks.length;i++){cbks[i].checked=o.checked;}}</script>
解决方案五:
学习了...