Hi. Im pretty new to js so bare with me. I have a piece of a script that grabs all of the checkboxes within a specific div element and puts them into the allInputs variable and then loops through the allInputs variable to find the checkbox with a specific id and puts that checkbox in the mainGroupInput variable and toggles the checkbox appropriately. The code works perfectly in normal browsers like FF and Safari, but no luck in IE.
The problem seems to be at the .getAttribute(‘id’). IE simply wont grab the id of the element that it is on. Ive tried .getAttributeNode(‘id’).value, attributes[‘id’]. Nothing seems to work. I’ve been reading up on .getAttribute() method for IE and it looks sorta weird, but i cant find anything that has a solution for my problem.
mainContainer=document.getElementById(mC);
allInputs=mainContainer.getElementsByTagName(‘input’);
for(e=0; e<allInputs.length; e++) {
// this is where it fails in IE. it wont grab the id of the current input
if(allInputs[e].getAttribute(‘id’) == (g_id+’_’+(sib_id-1))) {
mainGroupInput=allInputs[e];
alert(allInputs[e].getAttribute(‘id’)); // works in FF
alert(allInputs[e].attributes[‘id’].value); // works in FF
if(mainGroupInput.checked==true) {
alert(‘checked’);
} else {
alert(‘unchecked’);
}
}
}