html - Javascript Checking doesn't Work in IE7 -


i have following html edited shorter , more understandable:

<input type='checkbox' name='all' value='all' id='all' onclick='toggleall(this)'/>     <label for='all'> everyone</label> <input type='checkbox' name='resp' value='resp' id='resp' onclick='toggleresp(this)'/>     <label for='resp'> responsibles</label> <input type='checkbox' name='9' value='9' id='9' onclick='toggledept(this)' />     <label for='9'> department 9</label> <input type='checkbox' name='3-9-9' value='3-9-9' id='3-9-9' />     <label for='3-9-9'> responsible personnel 9</label> <input type='checkbox' name='4-9-10' value='4-9-10' id='4-9-10' />     <label for='4-9-10'> general personnel 10</label> <input type='checkbox' name='4-9-11' value='4-9-11' id='4-9-11' />     <label for='4-9-11'> general personnel 11</label> 

in name 4-9-10, 4 stands user type, if it's below 4 user responsible. 9 stands department id , 10 stands personnel id.

when click on checkbox all, of checkboxes checked:

function toggleall(source) {     inputs = document.getelementsbytagname("input");     (var in inputs) {         if(inputs[i].type == "checkbox") {             inputs[i].checked = source.checked;         }     } } 

when click on checkbox resp, of responsible personnels' checkboxes checked:

function toggleresp(source) {     inputs = document.getelementsbytagname("input");     (var in inputs) {         if (inputs[i].type == "checkbox") {             if(parseint(inputs[i].name.substring(0, inputs[i].name.indexof("-"))) < 4)                 inputs[i].checked = source.checked;         }     } } 

when click on department checkbox, department's personnels' checkboxes checked:

function toggledept(source) {     inputs = document.getelementsbytagname("input");     deptid = source.name;     (var in inputs) {         if (inputs[i].type == "checkbox") {             index = inputs[i].name.indexof("-");             lastindex = inputs[i].name.lastindexof("-");             ideptid = inputs[i].name.substring(index + 1, lastindex);             if (index != -1 && ideptid == deptid.tostring())                 inputs[i].checked = source.checked;         }     } } 

i have 3 departments , varying number of personnel in those. works great in firefox, chrome , yandex. however, partially works in ie7. example, when press on all, department responsibles , departments checked, department isn't checked @ all. responsible check , department works partially, too.

my question is: there function or html element here in codes isn't compatible earlier versions of ie7?

you see problem open debugger in ie 7 - press f12

'inputs[...].type' null or not object

ie not '9' id , throws exception when runs inputs[i] 9 id

as mplungjan mentioned, better modify javascript below. modified first 1 though

function toggleall(source) {     inputs = document.getelementsbytagname("input");     (var i=0; i<inputs.length; i++) {         var input = inputs[i];         if(input.type == "checkbox") {             input.checked = source.checked;         }     } } 

Comments