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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:24:08+00:00 2026-05-25T02:24:08+00:00

Hi I have 2 tables like this with some checkbox for filter the table:

  • 0

Hi I have 2 tables like this with some checkbox for filter the table:

<label><input type="checkbox" name="chk_filter_Grocery_1" id="chk_filter_Grocery_1_1" value="1;">Alamond</label>
<label><input type="checkbox" name="chk_filter_Grocery_1" id="chk_filter_Grocery_1_2" value="14;">Apple</label>
<label><input type="checkbox" name="chk_filter_Grocery_1" id="chk_filter_Grocery_1_3" value="5;6;">Lemon & Orange</label>
<label><input type="checkbox" name="chk_filter_Grocery_1" id="chk_filter_Grocery_1_4" value="17;">Coconut</label>

<table width="620px" id="Grocery-NA768">
    <tbody>
        <tr class="14">
            <td width="185" height="35" align="left">Apple</td>
            <td width="65" height="35" align="center" valign="middle">3 Kg</td>
            <td width="80" height="35" align="center" valign="middle">28/07/2011</td>
        </tr>
        <tr class="5">
            <td height="35" align="left">Lemon</td>
            <td height="35" align="center" valign="middle">5 Kg</td>
            <td height="35" align="center" valign="middle">28/07/2011&nbsp;</td>
        </tr>
        <tr class="17">
            <td height="35" align="left">Coconut</td>
            <td height="35" align="center" valign="middle">4 Kg</td>
            <td height="35" align="center" valign="middle">28/07/2011&nbsp;</td>
        </tr>
        <tr class="14">
            <td height="35" align="left">Apple</td>
            <td height="35" align="center" valign="middle">2 Kg</td>
            <td height="35" align="center" valign="middle">27/04/2011&nbsp;</td>
        </tr>
        <tr class="1">
            <td height="35" align="left">Almond</td>
            <td height="35" align="center" valign="middle">3 Kg</td>
            <td height="35" align="center" valign="middle">27/04/2011&nbsp;</td>
        </tr>
        <tr class="6">
            <td height="35" align="left">Orange</td>
            <td height="35" align="center" valign="middle">3 kg</td>
            <td height="35" align="center" valign="middle">27/04/2011&nbsp;</td>
        </tr>
    </tbody>
</table>

<label><input type="checkbox" name="chk_filter_Wine_1" id="chk_filter_Wine_1_1" value="51;">Brunello di Montalcino</label>
<label><input type="checkbox" name="chk_filter_Wine_1" id="chk_filter_Wine_1_2" value="4;">Dolcetto</label>
<label><input type="checkbox" name="chk_filter_Wine_1" id="chk_filter_Wine_1_3" value="35;64;">Pinot noir & Pinot blanc</label>
<label><input type="checkbox" name="chk_filter_Wine_1" id="chk_filter_Wine_1_4" value="72;">Shiraz </label>
<table width="620px" id="Wine-NA768">
    <tbody>
        <tr class="4">
            <td width="185" height="35" align="left">Dolcetto</td>
            <td width="65" height="35" align="center" valign="middle">3 b</td>
            <td width="80" height="35" align="center" valign="middle">28/07/2011</td>
        </tr>
        <tr class="35">
            <td height="35" align="left">Pinot blanc</td>
            <td height="35" align="center" valign="middle">5 b.</td>
            <td height="35" align="center" valign="middle">28/07/2011&nbsp;</td>
        </tr>
        <tr class="72">
            <td height="35" align="left">Shiraz</td>
            <td height="35" align="center" valign="middle">4 b.</td>
            <td height="35" align="center" valign="middle">28/07/2011&nbsp;</td>
        </tr>
        <tr class="14">
            <td height="35" align="left">Dolcetto</td>
            <td height="35" align="center" valign="middle">2 b.</td>
            <td height="35" align="center" valign="middle">27/04/2011&nbsp;</td>
        </tr>
        <tr class="51">
            <td height="35" align="left">Brunello di Montalcino</td>
            <td height="35" align="center" valign="middle">3 b.</td>
            <td height="35" align="center" valign="middle">27/04/2011&nbsp;</td>
        </tr>
        <tr class="64">
            <td height="35" align="left">Pinot noir</td>
            <td height="35" align="center" valign="middle">3 b.</td>
            <td height="35" align="center" valign="middle">27/04/2011&nbsp;</td>
        </tr>
    </tbody>
</table>

The two table have a different id (Grocery-NA768) and (Wine-NA768) and each checkbox has one or more (max 2) value (1;12;) and every of the table has the corresponding number as class.

I would like to filter the table clicking on the checkbox. I.e. when I click the apple checkbox (value 14) I want to see only the apple in the table (class 14), then if I click on the citrus (value 1;12;) checkbox I will see apple (class 14), lemon (class 5)and orange. If I deselect all the checkbox I will see the whole list.
Same thing for the wine table. I site new of jquery and I’ve found how to show or hide table row clicking on a checkbox but nothing similar to my needs.

Thanks in advance
Michele

  • 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-25T02:24:08+00:00Added an answer on May 25, 2026 at 2:24 am

    Working example: http://jsfiddle.net/petersendidit/6dNKA/3/

    See comments in the code:

    // Define some config objects and loop over them to get things set up
    $.each([{
        table: $("#Grocery-NA768"),
        inputs: $("input[name='chk_filter_Grocery_1']")
    },{
        table: $("#Wine-NA768"),
        inputs: $("input[name='chk_filter_Wine_1']")
    }],function(i, obj){
        var list = [];
        obj.inputs.click(function() {
            var that = $(this),
                value = that.val().match(/\d+/g),
                rows = obj.table.find("tr");
    
            // If its checked then add it to the list
            if ( that.prop("checked") ) {
                list = $.merge(list, value);
            } else {
                // if its not then remove the items from the list
                list = $.map( list, function( x ) {
                    return ( $.inArray( x, value ) > -1 ) ? null : x;
                });
            }
            // If the list has items
            if ( list.length ) {
                rows.hide() // hide all rows
                    .filter("."+list.join(",.")) // find the ones we care about
                    .show(); // and show them
            } else {
                // If no items in the list
                rows.show(); // show every row
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: <table> <tr><td><input type=checkbox id=checkbox1></input></td><td><input type=text disabled=disabled id=textInput1></input></td></tr> <tr><td><input type=checkbox
I have three tables like this: Person table: person_id | name | dob --------------------------------
I currently have a table structure that looks something like this(some details omitted): ColumnName
I have 2 tables like this: Stock Table product_id bigint(20) qty float Sales Table
I have a table like this: | Update | Name | Code | modification
I have two tables like this. Table A A_ID ( Primary Key) A1 A2
I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int
I have two tables like of this structure: content (content_id, content_type, user_id, time, comment_count)
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have 2 tables set up like this (irrelevant rows omitted): > product -

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.