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 5973195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:45:57+00:00 2026-05-22T20:45:57+00:00

most examples i have seen online have a snippet where they use 2 checkboxes,

  • 0

most examples i have seen online have a snippet where they use 2 checkboxes, one for just one checkbox (all) and the second is the checkboxlist. In myy case i have only one checkboxlist bound to datasource, example my datasource list options are(All,apple,orange,red,blue), I got most of it working except when everything is unchecked and i check the last item, example blue, it checks the ALL option. so not working properly. id is the id of the ‘All’ item in the list

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
 $(document).ready(function () {
     var id = "#<%=cbOptions.ClientID %>_0";
     var checkboxlistid = "#<%= cbOptions.ClientID %>";
     $(id).click(function () {
         $("#<%= cbOptions.ClientID %> input:checkbox").attr('checked', this.checked);
     });
     $(checkboxlistid +  " input:checkbox").click(function () {
         if ($(checkboxlistid).attr('value') != 0) {
             if ($(id).attr('checked') == true && this.checked == false) {
                 $(id).attr('checked', false);
             }
             else {
                 if ($(id).attr('checked') == true && this.checked == true)
                     CheckSelectAll();
             }

         }
     });
     function CheckSelectAll() {
         var flag = true;
         $(checkboxlistid + " input:checkbox").each(function () {
             if ($(checkboxlistid).attr('value') != 0) {
                 if (this.checked == false) {
                     flag = false;
                 }
                 else {
                     if ($(id).attr('checked') == true && this.checked == false) {
                         flag = false;
                     }
                     else {
                         flag = true;
                     }
                 }
             }
         });

         $(id).attr('checked', flag);
     }
      });    
         </script>
                <asp:CheckBoxList runat="server" ID="cbOptions" >
                </asp:CheckBoxList>
        </asp:Content>
  • 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-05-22T20:45:58+00:00Added an answer on May 22, 2026 at 8:45 pm
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var id = "#<%=cbOptions.ClientID %>_0";
                var checkboxlistid = "#<%= cbOptions.ClientID %>";
                $(id).click(function () {
                    $("#<%= cbOptions.ClientID %> input:checkbox").attr('checked', this.checked);
                });
                $(checkboxlistid + " input:checkbox").click(function () {
                if ($(id).attr('checked') == true && this.checked == false) {
                    $(id).attr('checked', false);
                }
                else 
                    CheckSelectAll();
                });
                function CheckSelectAll() {
                    $(checkboxlistid + " input:checkbox").each(function () {
                        var checkedcount = $(checkboxlistid + " input[type=checkbox]:checked").length;
                    var checkcondition = $(checkboxlistid + " input[type=checkbox]:").length - 1
                    if (checkedcount >= checkcondition)
                        $(id).attr('checked', true);
                    else
                        $(id).attr('checked', false);
                    });   
                }
            });    
             </script>
                    <asp:CheckBoxList runat="server" ID="cbOptions" >
                    </asp:CheckBoxList>
            </asp:Content>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most of the examples I have seen online have something similar to: FileOutputStream out
I just wondered, why most Delphi examples use FillChar() to initialize records. type TFoo
Most examples I've seen have scripts in a html page being enclosed by <!--
Most examples show how to redirect all subdomain traffic to a primary domain, maintaining
It seems like most examples of JPA/Hibernate entity bean classes I've seen do no
I am new to directx, but have been surprised that most examples I have
Example: I have an NSArray with 40 objects. What is the most efficient way
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
World's most convuluted title I know, an example should explain it better. I have
Most examples of creating remote branches involve pushing from a local branch Is there

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.