How to not count the select all checkbox RRS feed

  • Question

  • User1991482975 posted

    Hi i have a checkbox

    <b><i class="fa fa-check "></i> @ViewRes.Shared.Select-DeselectAll</b> <input type="checkbox" name="checkAll" id="checkAll"> 

    wich allow me to check all the others checkboxes

    <input type="checkbox" name="tagspurchased" value="@Model[i].PartnerAdvertiseMailId" id="@Model[i].PartnerAdvertiseMailId">

    i done this script in order to show and hide a div and show th count of the selected checkboxes

    <script type="text/javascript">
        $(document).ready(function () {
            var $checkboxes = $('#purchase-form input[type="checkbox"]');
            $checkboxes.change(function () {
                var countCheckedCheckboxes = $checkboxes.filter(':checked').length;
                if((countCheckedCheckboxes) > 0)
                if ((countCheckedCheckboxes) < 1) {

    my div

    <div class="count-checkboxes-wrapper">
                                <span id="count-checked-checkboxes">0</span> checked

    the problem is that i do not wanna count the SELCT ALL checkbox in case is selected.. but only the others checkboxes

    How to do

    Thursday, December 24, 2020 10:30 AM

All replies

  • User475983607 posted

    Just get the count of all the selected checkboxes.  The write basic logic that checks "if" the checkAll checkbox is checked.  If the checkAll check box is checked then subtract one for the count.

    Thursday, December 24, 2020 1:49 PM
  • User1991482975 posted

    Please stop answering , just to get points.

    If you don not have the time to write the code for the answer, avoid answering my post.


    Thursday, December 24, 2020 3:01 PM
  • User-474980206 posted

    Just filter out the select all by a common property. If they are all named checkAll, use name otherwise add a common class.

    var countCheckedCheckboxes = $checkboxes.filter(':checked').not(‘[name=“CheckAll”]’).length;
    Thursday, December 24, 2020 3:47 PM