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
- 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
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
Richand said:
Thanks a lot for the script! It was exactly what I was looking for and it worked like a charm.
Larry Solheim said:
No site yet, but am looking to create one for a car club. For an email feature I will read names into an array from a mySQL database, then list them on the website where members can send emails to other members (access is password protected). This seeems to work as written, but it is a lot oc "checking" to select all 36 members. Could your script be made to work w/ these prelisted, variable entries?
--Larry
Home
New Page 1
Contact the Members
Your Name (sender):
Subject:
Select Addressees:[ See Responses ]
carol carol said:
how to select/unselect only some checkbox? I want to decid with of them to check nota ll
[ See Responses ]







