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

  • Home
  • SEARCH
  • 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 4026608
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:59:30+00:00 2026-05-20T10:59:30+00:00

I have three tables, one listing contacts, the other users, and the last emails.

  • 0

I have three tables, one listing contacts, the other users, and the last emails. The user can either select people individually, or click on a select all checkbox. When a person is selected the <TR> is highlighted, and if select all is check, then all users are highlighted. So far, so good.

The problem arises when checking the select all checkbox. This will select all <TR> in the <TABLE> and highlight them. However, it will also select/deselect all other <TR> in the other two tables.

Summarizing, individual selections within each <TABLE> work well. Select/deselect all does check all <TR> in the table and highlights them, however it also checks <TR> in other tables, which is the problem I am trying to solve.

A nice, but not necessarily need to have, would be to use only one function which suits the 3 tables rather than 3 functions.

To get the whole picture: http://jsfiddle.net/moodas/C3dhm/8/

jQuery below:

    $(document).ready(function() {
    // CONTACTS 
    $("#checkallContacts").live('click',function(event) {
    $('input:checkbox:not(#checkallContacts)').attr('checked',this.checked);
    //To Highlight
    if ($(this).attr("checked") == true) {
        $("#tblDisplayContacts").find('tr:not(#chkrowContacts)').css("background-color","#FC9A01"); }
    else {
        $("#tblDisplayContacts").find('tr:not(#chkrowContacts)').css("background-color","#FFF"); }
});

$('input:checkbox:not(#checkallContacts)').live('click',function(event) {
    if($("#checkallContacts").attr('checked') == true && this.checked == false) {
        $("#checkallContacts").attr('checked',false);
        $(this).closest('tr').css("background-color","#ffffff"); }
    if(this.checked == true) {
        $(this).closest('tr').css("background-color","#FC9A01");
        CheckSelectAll(); }
    if(this.checked == false) {
        $(this).closest('tr').css("background-color","#ffffff"); }
});

function CheckSelectAll() {
    var flag = true;
    $('input:checkbox:not(#checkallContacts)').each(function() {
        if(this.checked == false) {
            flag = false; }
    });
    $("#checkallContacts").attr('checked',flag);
}

// USERS    
$("#checkallUsers").live('click',function(event) {
    $('input:checkbox:not(#checkallUsers)').attr('checked',this.checked);
    //To Highlight
    if ($(this).attr("checked") == true) {
        $("#tblDisplayUsers").find('tr:not(#chkrowUsers)').css("background-color","#FC9A01"); }
    else {
        $("#tblDisplayUsers").find('tr:not(#chkrowUsers)').css("background-color","#FFF"); }
});

$('input:checkbox:not(#checkallUsers)').live('click',function(event) {
    if($("#checkallUsers").attr('checked') == true && this.checked == false) {
        $("#checkallUsers").attr('checked',false);
        $(this).closest('tr').css("background-color","#ffffff"); }
    if(this.checked == true) {
        $(this).closest('tr').css("background-color","#FC9A01");
        CheckSelectAll(); }
    if(this.checked == false) {
        $(this).closest('tr').css("background-color","#ffffff"); }
});

function CheckSelectAll() {
    var flag = true;
    $('input:checkbox:not(#checkallUsers)').each(function() {
        if(this.checked == false) {
            flag = false; }
    });
    $("#checkallUsers").attr('checked',flag);
}

// EMAIL    
$("#checkallEmail").live('click',function(event) {
    $('input:checkbox:not(#checkallEmail)').attr('checked',this.checked);
    //To Highlight
    if ($(this).attr("checked") == true) {
        $("#tblDisplayEmail").find('tr:not(#chkrowEmail)').css("background-color","#FC9A01"); }
    else {
        $("#tblDisplayEmail").find('tr:not(#chkrowEmail)').css("background-color","#FFF"); }
});

$('input:checkbox:not(#checkallEmail)').live('click',function(event) {
    if($("#checkallEmail").attr('checked') == true && this.checked == false) {
        $("#checkallEmail").attr('checked',false);
        $(this).closest('tr').css("background-color","#ffffff"); }
 if(this.checked == true) {
        $(this).closest('tr').css("background-color","#FC9A01");
        CheckSelectAll(); }
    if(this.checked == false) {
        $(this).closest('tr').css("background-color","#ffffff"); }
});

function CheckSelectAll() {
    var flag = true;
    $('input:checkbox:not(#checkallEmail)').each(function() {
        if(this.checked == false) {
            flag = false; }
    });
    $("#checkallEmail").attr('checked',flag);
}   
    });
  • 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-20T10:59:31+00:00Added an answer on May 20, 2026 at 10:59 am

    You could do something like this:

    $("#checkallContacts").live('click', function(event) {
        $("#tblDisplayContacts").find("input[type=checkbox]").attr('checked', this.checked);
        //To Highlight
        if ($(this).attr("checked") == true) {
            $("#tblDisplayContacts").find('tr:not(#chkrowContacts)').css("background-color", "#FC9A01");
        }
        else {
            $("#tblDisplayContacts").find('tr:not(#chkrowContacts)').css("background-color", "#FFF");
        }
    });
    

    On a side note, you are using live quite a bit, are all of these tables built dynamically?

    Also looking at your example I think this can be simplified to the following this relies on a convention for your tables by class name and removes the need for an id:

    $(".checkAll").live("click", function() {
        var $table = $(this).parents("table.t");
        $table.find("input[type=checkbox]").attr('checked', this.checked);
        //To Highlight
        if ($(this).attr("checked") == true) {
            $table.find('tr').css("background-color", "#FC9A01");
        }
        else {
            $table.find('tr').css("background-color", "#FFF");
        }
    });
    
    $("input[type=checkbox]:not(.checkAll)").live("click", function() {
        var $table = $(this).parents("table.t");
        var $checkAll = $table.find(".checkAll");
        var $row = $(this).parents("tr.trBorderLight");
        var totalChecked = $table.find(":checked:not(.checkAll)").length;
        var totalCheckBoxes = $table.find("input[type=checkbox]:not(.checkAll)").length;
        if ($(this).attr("checked") == true) {
            $row.css("background-color", "#FC9A01");
            if (totalChecked == totalCheckBoxes) {
                $checkAll.attr("checked", true);
                $checkAll.parents("tr.trBorder").css("background-color", "#FC9A01");
            }
        }
        else {
            $row.css("background-color", "#FFF");
            $checkAll.parents("tr.trBorder").css("background-color", "#FFF");
            $checkAll.attr("checked", false);
        }
    });
    

    Here is an example of this on jsfiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four tables. Three of them are tables with one key and they
I have a table which needs to link one of three seperate tables, but
I have two tables. One is a listing of products, and one is a
In the tablet layout of my app, I have three ListFragments and one regular
I have a table column where each row has one of three states, and
I have a composite index on three column in one of my table. It
I have two product tables Product1 and Product2. There is a one 2 one
I have three database tables defined below, column names mentioned in parenthesis: Product (ProductID,
I have a number of tables in SQL. One is Controls (a typical CRUD
I've got three tables which all join into one table. Here is the code:

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.