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

The Archive Base Latest Questions

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

I have a form with four dropdowns, each with X amount of values listed;

  • 0

I have a form with four dropdowns, each with X amount of values listed;

Subject, Type, Month, Location

And then I have a table with multiple rows pulled from a database with the exact same column headers.

Subject, Type, Month, Location

Each row of data is different.

I want to build a filter system where the $(select).change function comes in, builds an array of values from all selected dropdowns, and then applys the jquery hide/show function wherever it corresponds. The table rows have classes assigned to them dynamically eg:

<tr class="subjectVal typeVal monthVal locationVal"><td>lorem ipsum</td>...</tr>

At the moment I have:

$("form select").change(function() {

    var values = [];        
    $("form select").each(function() {
        if ($(this).val() != "Please select...") {
            values.push($(this).val());
        }
    });

    $("table.events tr.row").each(function() {
        tr = $(this);
        $.each( values, function(index, item){
            if (!$(tr).hasClass(item)) {
                $(tr).hide();

            } else {
                $(tr).show();
            }
        });

    });

});

But this if the value array contains more than one item, only that item is filtering the table. If I choose a subject, then choose a location, it will always show all of those locations regardless of the subject I have chosen.

  • 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-27T02:53:09+00:00Added an answer on May 27, 2026 at 2:53 am

    So basically it should only show the row if all values match? If so then this code should work:

    $("table.events tr.row").each(function() {
        var tr = $(this), show = true;
        $.each( values, function(index, item){
            if (!tr.hasClass(item)) {
                show = false;
            }
        });
        tr.toggle(show);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four tables each with its own form, all these table share same
I have a form with four values. If any of them are empty I
I am using windows application and I have four combo boxes(comboeventname,combosendtype,comboType,comboschedule) in that form....
i have a small form with four EditText fields in which second EditText is
I have data in the form of four columns. The first three columns represent
I have a form and up the top it contains four different radio buttons
I have have a simple HTML form with say four input widgets (see below)...two
I have a form with four different fieldsets. For jQuery validation, I would like
I have a form and it contains four fields. Two of these fields are
I have an upload form and am checking the file size and file type

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.