How do you toggle all checkboxes on a form using javascript?

I want a button that will toggle the checkboxes in a form.

Related tags: HTML JavaScript

Credit: own experience, modified version of http://javascript.internet.com/forms/check-all-toggle-switch.html

function toggle_checkboxes(checkname) {
for (var i=0; i<checkname.length; i++) {
checkname[i].checked = !(checkname[i].checked);
}
}

Rating: 1

Propose a different solution...