Javascript/jQuery check all check boxes function.

June 16, 2008 – 12:14 pm

You would think a check all function would be pretty easy in jQuery, and it is if all of the checkboxes have the same name. If they don't things get tricky.

In this example, I have an anchor named chk_all that the user can click to check all. All of my checkboxes to be checked are in a table named search_results.

  1.  
  2. var toggle = 1;
  3. $("#chk_all").click(function(){
  4. $("#search_results").find("input[@type$='checkbox']").each(function(){
  5. if(toggle) {
  6. this.checked = true;
  7. }
  8. else {
  9. this.checked = false;
  10. }
  11.  
  12. });
  13. if(toggle) {
  14. toggle = 0;
  15. }
  16. else {
  17. toggle = 1;
  18. }
  19. return false;
  20. });
  21.  

Sorry, comments for this entry are closed at this time.



thevedic.net

Part of the thevedic.net.
[Contact Me] - [Mud Emporium] - [Ozark, AR] - [See my Port?]

This site is in no way represents the opinions or positions of any company or organization including those who employ the creators of this web site. We're not responsible for the content, posts, responses by other users or ideas of any sites that are linked to on this page. This site is recommended for ages 18 and up.

VEDIC VEKO IS PROSPEROUS

Arkie Imports | Dean Vaughan | Dean Vaughan | K. Dean Vaughan | Kenneth Vaughan | Pig Trail 23 | Pig Trail Pics | See My Port Forward Info | See My Port Forward Info


I'm not affiliated with the following in anyway.
Arkansas MMA - Inferno Mixed Martial Arts - Inferno Martial Arts Club - Inferno Martial Arts Club - Official Inferno Fight Gear - Inferno Fight Equipment - Inferno Combat Gear - IFC Online - Inferno Fight Gear - Inferno MMA - Inferno Fight Gear