I've got some trouble building a select all checkbox inside a table. Originally the table has several rows and the first checkbox should be used to select all options.
I built a small example, but still could not figure out my mistake.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "httpd://www.w3.org/TR/html4/loose.dtd">
<html><head>
<script language="JavaScript">
function allClicked(clickedId)
{
  var divId = "div-" + clickedId.substring(4);
  var child = document.getElementById( divId );
  var tdChildren = child.getElementsByTagName("td"); // appears to be empty
  var allCheckBox = document.getElementById( clickedId );
  var setTo = allCheckBox.checked ? true : false;
  for (var i=0; i<tdChildren.length; ++i) {
    tdChildren[i].elements.checked = setTo;
  }
}
</script>
</head><body>
<div id="div-a">
  <table>
    <tr>
      <td><input id="all-AP" onClick="javascript:allClicked('all-AP')" type="checkbox">Select All</td>
      <div id="div-AP">
      <td><input id="AP_A1K" checked="checked" type="checkbox"></td>
      <td><input id="AP_A2K" checked="checked" type="checkbox"></td>
      <td><input id="AP_A3K" type="checkbox"></td>
      </div>
    </tr>
  </table>
</div>
</body></html>
During debugging the div with id="all-AP" is retrieved but appears to be empty. I expected it to have three td-elements in it.
Is a div separating the td's valid? What should I fix?
 
     
     
    