Parent class
CopyCode The Code is as follows: <input type = "checkbox" name = "father" forcheckboxgroup = "groupname1"/>
SubclassCopy codeThe Code is as follows: <input type = "checkbox" name = "son" group = "groupname1"/>
Implementation Code copy Code the code is as follows:
function _ getgroupmember (o) {
var groupname = O. getattribute ('forcheckboxgroup');
var items = new array;
var inputs = document. getelementsbytagname ('input');
var I = 0;
while (I If (inputs [I]. type = 'checkbox') {
var groupattrib = inputs [I]. getattribute ('group');
If (groupattrib = groupname) {
items [items. length] = inputs [I];
var master = inputs [I]. getattribute ('groupmaster');
If (Master = NULL) {
master = new array;
master [0] = O. uniqueid;
inputs [I]. setattribute ('groupmaster', Master);
}< br> else {
master [master. length] = O. uniqueid;
}< br> inputs [I]. onpropertychange = function () {
If (event. propertyname = 'checked') {
var ARRO = This. getattribute ('groupmaster');
var I = 0;
while (I _ setstate (document. getelementbyid (ARRO [I]);
I ++;
}< BR >}< br> I ++;
}< br> return items;
}
Function _ setstate (o ){
VaR master = O;
If (master! = NULL ){
VaR chkselall = true;
VaR chknosel = true;
VaR groupmember = Master. getattribute ('groupmember ');
VaR I = 0;
While (I <groupmember. Length ){
If (chkselall) chkselall = groupmember [I]. checked;
If (chknosel) chknosel =! Groupmember [I]. checked;
I ++;
}
If (master. tagname. tolowercase () = 'input' & master. type = 'checkbox '){
If (chkselall ){
Master. Indeterminate = false;
Master. Checked = true;
}
If (chknosel ){
Master. Indeterminate = false;
Master. Checked = false;
}
If (! Chkselall &&! Chknosel) master. Indeterminate = true;
}
Else {
Master. Disabled = chknosel;
}
}
}
Window. attachevent ('onload', checkboxgroup );
</SCRIPT>