I have this code working but I can not figure out the last element. how do you get the "checkall" check box to be checked if all of the child check boxes are checked one at a time?


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<script type="text/javascript">

function checkall(bu) {
var el, i=1;
while(el=document.getElementById(bu.id +(i++))) el.checked = bu.checked;
}
function checkall2(bu) {
var c = document.getElementById(bu.id.replace(/\d/,""));
!bu.checked ? c.checked=false : null;


}
</script>
<body>
<form id="form1" runat="server">
<div>

<asp:CheckBox ID="c" runat="server" onclick="checkall(this)"/>Check/Uncheck All
<input type="checkbox" value="" id="c1" onclick="checkall2(this)"/>Abc
<input type="checkbox" value="" id="c2" onclick="checkall2(this)"/>Def
<input type="checkbox" value="" id="c3" onclick="checkall2(this)"/>Geh
<p>
<input type="checkbox" value="" id="d" onclick="checkall(this)"/>Check/Uncheck All
<input type="checkbox" value="" id="d1" onclick="checkall2(this)"/>Ijk
<input type="checkbox" value="" id="d2" onclick="checkall2(this)"/>Lmn
<input type="checkbox" value="" id="d3" onclick="checkall2(this)"/>Opq
<p>
<input type="checkbox" value="" id="e" onclick="checkall(this)"/>Check/Uncheck All
<input type="checkbox" value="" id="e1" onclick="checkall2(this)"/>Rst
<input type="checkbox" value="" id="e2" onclick="checkall2(this)"/>Uvw
<input type="checkbox" value="" id="e3" onclick="checkall2(this)"/>Xyz

</div>

</form>

</body>
</html>