Select All Checkboxes in a Form with JavaScript
This simple JavaScript function allows you to quickly select or unselect all the checkboxes in a form.
NOTE: This function was updated on January 4, 2006 to work no matter where you place the event handler checkbox named "checkall". Also... there is a more versatile function called checkUncheckSome() that has more control.
function checkUncheckAll(boxController)
To use this function place the following code inside the head of your HTML:
Please include credit when using this script and read this site's Terms & Conditions before using. Using this code and applying an input with the name of "checkall" you can select or unselect all checkboxes.
Example:
Example code below:
<form><input type="checkbox" name="check1"/> <br/> <input type="checkbox" name="check2"/> <br/> <input type="checkbox" name="check3"/> <br/> <input type="checkbox" name="check4"/> <br/> <input type="checkbox" name="check5"/> <br/> <input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/>select/unselect</form>
More in the Free Useful Javascripts Series
- Altering CSS Class Attributes with JavaScript
- Change HTML Styles with JavaScript
- Select Some Checkboxes JavaScript Function
- Select All Checkboxes in a Form with JavaScript
- Get a Form Element's Label with JavaScript
- Select Radio Inputs JavaScript
- UseMaps Crash IE When Changed
- Hide Select Menus JavaScript
- Manipulating Element Styles Based on CSS Classes Using Prototype
- Search for JavaScript articles similar to "Select All Checkboxes in a Form with JavaScript.
- Search all articles similar to "Select All Checkboxes in a Form with JavaScript".
- List JavaScript articles from all authors.
Comments on Select All Checkboxes in a Form with JavaScript
vicky shrestha said:
thank u so much it worked..
Boros Csaba said:
If somebody is interested I have a post abouthow to check or uncheck all checkboxes using a button.
Mark Iliff said:
Good stuff. Thanks for sharing.
roboMachine MAN said:
Why don't you make it open source?
Dusty Roberts said:
This article could also assist: http://laymensterm.blogspot.com/2008/12/javascript-select-all-none-checkboxes.html
Matthew Jenne said:
Great script. Just one question. How could I get it to work with more than one checkbox group??
Thanks
gus wah said:
I'd like a checkbox that, when checked, UNCHECKS the other checkboxes in a single array. Is there a simple mod to your script that would do this?
Ijustwaisted 30minsofmylife said:
If the script does work, you need to explain in further detail what is required.
Your own script doesnt work on your own page with only a different server and the source 100% intact, that's no good.
Shawn Olson said:
I am sorry that the script was temporarily broken. While loading an update to the JavaScript file, it appears that there was corruption with the file. I have reloaded the file... so it should work fine now.[ See Responses ]
Patricia Hswe said:
Is there an error in the code on this page:
http://www.shawnolson.net/scripts/public_smo_scripts.js
where the code reads:
}iteCheckRound]);
What is "ite"?
Thanks,
Patricia
Al Smith said:
I can get this to work perfectly when using firefox but in IE7 for some reason it does nothing - any idea what I could be doing wrong?
jo jo said:
hi, great code
but, how to make some exception ?
tks
Jerome Uy said:
perfecto!! work like a charm!
Riaan Venter said:
Thanks Shawn, just what I needed!
Nick ConeDog said:
Worked perfectly! Thanks!
Kelvin Wright said:
Thanks for this - just what I needed - something short and sweet
John Eubanks said:
Awesome script. I was looking for something to use with dynamic checkboxes in coldfusion. Most scripts deal with static text boxes, which don't work very well. Thank you very much, a very nice piece of work.
roopesh gottipati said:
it is damn good
govind gupta said:
no
Bala Chandar said:
Simply Perfection!
All The Best
More Posts
- 1
- 2







