Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8284723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:12:49+00:00 2026-06-08T11:12:49+00:00

Possible Duplicate: Javascript or Jquery to check and uncheck all checkbox I have 12

  • 0

Possible Duplicate:
Javascript or Jquery to check and uncheck all checkbox

I have 12 asp:checkboxes on a page and I would like to add one which selects/deselects all of them.
What’s the best way to do that?

I’ve seen people use jquery but I’m not very familiar with JS.
IS there a generic jquery finction to use?

<head>...
   <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
...</head>

<body>...
    <script type="text/javascript">
        function Selectall() {
            if ($('.JchkAll').is(':checked')) {
                // .JchkGrid cssClass will be assigned to all other checkboxes in your control 
                $('.JchkGrid').attr('checked', 'true');
            }
            else {
                $('.JchkGrid').removeAttr('checked', 'false');
            }
        } 
    </script>
<form>...
<asp:CheckBox runat="server" ID="cbSelectAll" Text="Select/Deselect All" CssClass="JchkAll" onchange="Selectall();"/>
        <asp:CheckBox runat="server" ID="cbName" Text="Name" class="JchkGrid"/>
        <asp:CheckBox runat="server" ID="cbModel" Text="Model" CssClass="JchkGrid"/>
...</form>
...</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:12:52+00:00Added an answer on June 8, 2026 at 11:12 am

    Give your chckbox a css class and try this way

    // .JchkAll is cssclass of your checkbox on which's click you need to check all Checkboxes

    function Selectall() {
      if ($('.JchkAll').is(':checked')) {
       // .JchkGrid cssClass will be assigned to all other checkboxes in your control
        $('.JchkGrid').attr('checked', 'true');
      }
      else {
        $('.JchkGrid').removeAttr('checked', 'false');
      }
    }
    

    Edit:

    Also Don’t forget to add this on checkbox’s onchange attribute..

    <asp:CheckBox runat="server" onchange="Selectall();" ID="cbSelectAll" 
         Text="Select/Deselect All" CssClass="JchkAll"/>
    

    But this will give you a compiler warning…it would be better if you add it from code behind on Page_Load event like

        cbSelectAll.Attributes.Add("onchange","Selectall");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Clearing all cookies with javascript I would like to have a checkbox
Possible Duplicate: select all checkboxes command jquery, javascript I am having trouble selecting all
Possible Duplicate: How do I check a checkbox with JQuery or Javascript? I'm trying
Possible Duplicate: Prevent any form of page refresh using jQuery/Javascript how can i prevent
Possible Duplicate: $(document).ready equivalent without jQuery I have a framework-less javascript that executes on
Possible Duplicate: JQuery to check for duplicate ids in a DOM Suppose i have
Possible Duplicate: Can JQuery UI and JQuery tools work together? I have a page
Possible Duplicate: jQuery/Javascript collision detection What would be the best way using preferably using
Possible Duplicate: jQuery/Javascript function to clear all the fields of a form I need
Possible Duplicate: javascript: pause setTimeout(); Im using jQuery and working on a notification system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.