0

Hi there,

I have a row of checkboxes and I want the following: -
when clicking the child it has to select/unselect all parent checkboxes - and you uncheck one of the child checkboxes, the parent should also uncheck.

Here parent ->child select/unselect attached.

<script language="JavaScript">
function checkAll(theForm, cName, status) {
for (i=0,n=theForm.elements.length;i<n;i++)
  if (theForm.elements[i].className.indexOf(cName) !=-1) {
    theForm.elements[i].checked = status;
  }
}
</script>

<form id="selectForm">  
<input type="checkbox" name="selected" value="01" class="results2"><br>
<input type="checkbox" name="selected" value="02" class="results2"><br>
Select All/None <input type="checkbox" onclick="checkAll(document.getElementById('selectForm'), 'results2', this.checked);" />
</form>
2
Contributors
2
Replies
15
Views
2 Years
Discussion Span
Last Post by fireburner29
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.