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>
- Free Useful Javascripts
Links to articles that give free javascript code or javascript examples.
- 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
- Compare Values with Arbitrary Comparison Operator
- Related Topics
jay
Dec 27, 2012
Reply
sonal
Sep 27, 2012
Reply
vikas gupta
Mar 17, 2011
Reply
Noble Silence
Feb 8, 2011
Reply
vicky shrestha
Aug 19, 2010
Reply
Boros Csaba
Apr 7, 2010
Reply
Mark Iliff
Dec 11, 2009
Reply
Dusty Roberts
Dec 24, 2008
Reply
Matthew Jenne
Nov 10, 2008
Reply
gus wah
Oct 27, 2008
Reply
Ijustwaisted 30minsofmylife
May 28, 2008
Reply
Shawn Olson
May 21, 2008
Reply
Sujith Kumar
Aug 13, 2008
Reply
Patricia Hswe
May 21, 2008
Reply
Al Smith
Mar 3, 2008
Reply
jo jo
Nov 7, 2007
Reply
Jerome Uy
Sep 7, 2007
Reply
Riaan Venter
Jul 9, 2007
Reply
Nick ConeDog
May 16, 2007
Reply
Kelvin Wright
Feb 1, 2007
Reply
John Eubanks
Jan 10, 2007
Reply
roopesh gottipati
Dec 22, 2006
Reply
govind gupta
Dec 3, 2006
Reply
Bala Chandar
Nov 27, 2006
Reply
Richand
Aug 31, 2006
Reply
Larry Solheim
Aug 10, 2006
Reply
umar rehman
Feb 19, 2009
Reply
carol carol
Jul 25, 2006
Reply
Shawn Olson
Jul 25, 2006
Reply
Comment ignored.
Youcef Kelanemer
May 4, 2004
Reply