(e-mail address removed) said on 18/04/2006 12:05 PM AEST:
Your script is flawed (see below).
The simple solution is to include an HTML checked attribute, no need for
client scripting at all. An added bonus is that if you have a reset
button, resetting the form will return the checkboxes to checked.
<body onload="document.getElementsByTagName('input').checked=true">
getElementsByTagName returns an HTML collection object. It doesn't have
a checked property, giving it one and setting it to true will likely
have no useful impact on the document.
If you want to set all checkboxes to true using script, then loop
through the collection and set the checked property of the individual
items to true:
var allInputs = document.getElementsByTagName('input');
var input, i = allInputs.length;
while (i--){
input = allInputs
;
if ('checkbox' == input.type){
input.checked = true;
}
}