Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
Search :       Advanced Search �
Home

Author Rank :
Page Views :
Downloads : 0
Rating :
 Rate it
Level :
Become a Sponsor
Tags


Here is the jQuery implementation of Select All checkbox functionality inside a HTML table.

Try out the attached working sample.

HTML:

<table border="1">
<tr><th><input type="checkbox" id="selectall" /></th>
            <th>Heading1 </th><th>Heading2 </th>
</tr>
<tr>

<
td align="center">
  <
input type="checkbox" class="case" name="case" value="1" /> </td>
<td>Row1</td>
<td>Row1</td>
</tr>
<tr>
  <td align="center">

   <
input type="checkbox" class="case" name="case" value="2" /></td>
  <td>Row2</td>

  <
td> Row2</td>
</tr>

jQuery:

<script
type
="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js">
</
script>

 <script type="text/javascript" >
    $(document).ready(function() {
      // add multiple select / deselect functionality
        $("#selectall").click(function() {
        $('.case').attr('checked', this.checked);
         });
     // if all checkbox are selected, check the selectall checkbox  also        

     $(".case").click(function() {
        if ($(".case").length == $(".case:checked").length) {
        $("#selectall").attr("checked", "checked");
         }
        else {
        $("#selectall").removeAttr("checked");
         }     
         });
     });

    </script>

 Thanks shinu .

 [Top] Rate this article
 
 About the author
 
Author
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
 Comments

 � 2025  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.