Almost. You need to use index 1 of childNodes, not 0.
Otherwise, you need to remove the whitespace between the two tags.
http://jsfiddle.net/H9mc2/
window.toggle = function toggle(source) {
checkboxes = document.getElementsByClassName('Checkbox');
// alert(checkboxes.length);
for (var i = 0, n = checkboxes.length; i < n; i++) {
checkboxes[i].childNodes[1].checked = source.checked;
}
}
Also, if you have many checkboxes:
instead of selecting all, I would invert the selection, like
function invertCheckboxSelection(e)
{
e = e || event; /* get IE event ( not passed ) */
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
var strFormId = "form1";
var strCheckBoxId = "cbInvertSelection";
var ControlCheckbox = document.getElementById(strCheckBoxId);
ControlCheckbox.disabled = true;
var form = document.getElementById(strFormId);
for (var i = 0; i < form.elements.length; i++)
{
if (form.elements[i].type == 'checkbox')
{
if (form.elements[i].id != strCheckBoxId)
form.elements[i].checked = !form.elements[i].checked;
} // End if (form.elements[i].type == 'checkbox')
} // Next i
ControlCheckbox.disabled = false;
} // End Function invertCheckboxSelection