Looking for beta testers for WhizzyInvoice.com. Wanna help? Jump to: main content, navigation or the bottom.

To check all of the options, you can use:

<input type="button" name="Button" value="Check All" onclick="checkAll('test_form', true)" />

Or to uncheck all of the options you can use:

<input type="button" name="Button" value="Uncheck All" onclick="checkAll('test_form', false)" />

The above examples will check and uncheck all of the checkboxes that are in a form with the ID 'test_form'.

function checkAll(frm, checkedOn) {
// have we been passed an ID
if (typeof frm == "string") {
frm = document.getElementById(frm);
}

// Get all of the inputs that are in this form
var inputs = frm.getElementsByTagName("input");

// for each input in the form, check if it is a checkbox
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
inputs[i].checked = checkedOn;
}
}
}

If this has been of some help to you, let me know!


Got something to say?

Join the discussion! You know how these things work; enter your details and comments below and be heard.

If you have trouble reading the code, click on the code itself to generate a new random code.
 

Going up? Back to the top