I am trying to write some javascript which will check the checkboxes within a div where the checkbox name matches the given name. Here is what I have, but it isn’t doing anything:
function checkbox_control(container_id,element_name,status) {
var children = document.getElementById(container_id).childNodes;
alert(element_name);
for(var b=0; b < children.length; b++) {
if(children[b].name == element_name){
children[b].checked = status;
}
}
}
Try getElementsByTagName instead of childNodes (it makes recursive search of elements). LIke this: