Does anyone know of a function that can check all or uncheck all checkboxes with one click barring in mind i have multiple forms on one page.

function checkAll(formName, status){
for (i = 0; i < formName.length; i++)
formName[i].checked = status.checked? true:false
}

I have tried the above it works fine with one form and when there are only one choice to check all but i have multiple checkbox fields on this form.

Thank you

Did you want this action for only one of the forms on the page?
If not, perhaps just have the default setting to be checked or unchecked; then reload the page when you want the checkboxes to return to their default state.

Alternately, you might have to write a custom function that checks or unchecks the particular form you want affected.

Yes I want a function to be able to use on different field sets.
I guess I will spend a week doing it javascript is not my speciality I hate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.