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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.