Tip: you can modify some code before running
Js checkbox associated directory tree polar selection code<html><head><title>CheckBox</title><script type="text/javascript" defer="true">Function tag (tag) {var n = document. getElementsByTagName ("input"); alert (n. length); var C = new Array (); for (I = 0; I<n.length;i++)if (n.item(i).type=="checkbox") {n.item(i).CP=function(){var s=this.id;var n=s.lastIndexOf("_");if (n){var t=s.substring(0,n);for(i in C)if(C[i].id==t)return C[i];}};n.item(i).CA=function(){var s=this.id;for(i in C){if(C[i].id.indexOf(s)==0&&C[i]!==this){C[i].indeterminate=false;C[i].checked=this.checked;}}};n.item(i).CK=function(){var s=this.id+"_";var s1=true;var s2=true;for(i in C){if(C[i].id.indexOf(s)==0){s1=(s1&&C[i].checked);s2=(s2&&!C[i].checked)}}if(s1)return 2;else if(s2)return 1;else return 3;};n.item(i).onclick=function(){this.CA();var CN=this.CP();while (CN){if(CN.CK()<3){CN.indeterminate=false;CN.checked=CN.CK()-1;}else CN.indeterminate=true;CN=CN.CP();}};C.push(n.item(i));}}</script></head><body onload=tag()><input type="checkbox" name="a" id="a"><br><input type="checkbox" name="a" id="a_1"><br><input type="checkbox" name="a" id="a_1_1"><br><input type="checkbox" name="a" id="a_1_2"><br><input type="checkbox" name="a" id="a_1_2_1"><br><input type="checkbox" name="a" id="a_1_2_2"><br><input type="checkbox" name="a" id="a_1_2_2_1"><br><input type="checkbox" name="a" id="a_1_2_2_2"><br><input type="checkbox" name="a" id="a_1_2_2_3"><br><input type="checkbox" name="a" id="a_1_2_2_3_1"><br><input type="checkbox" name="a" id="a_1_2_2_3_2"><br><input type="checkbox" name="a" id="a_1_2_2_3_3"><br><input type="checkbox" name="a" id="a_1_2_2_4"><br><input type="checkbox" name="a" id="a_1_2_3"><br><input type="checkbox" name="a" id="a_1_3"><br><input type="checkbox" name="a" id="a_1_4"><br><input type="checkbox" name="a" id="a_2"><br><input type="checkbox" name="a" id="a_3"><br><input type="checkbox" name="a" id="a_4"><br><hr><input type="checkbox" name="b" id="b"><br><input type="checkbox" name="b" id="b_1"><br><input type="checkbox" name="b" id="b_1_1"><br><input type="checkbox" name="b" id="b_2"><br><input type="checkbox" name="b" id="b_3"><br><input type="checkbox" name="b" id="b_4"><br></body></html>
Tip: you can modify some code before running