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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:54:39+00:00 2026-06-07T06:54:39+00:00

I am trying to get a product filter working which is almost there. I

  • 0

I am trying to get a product filter working which is almost there. I want to the user to be able to select shirt, which then shows all shirts then blue which shows all blue shirts and then in they check pink it shows all blue and pink shirts. At the moment I can only get it to show if all conditions are true but I want it to show if any of that dataset is true

My fiddle is here

http://jsfiddle.net/ktcle/2keVN/2/

$('div.tags').delegate('input[type=checkbox]', 'change', function()
{
var $lis = $('.results > li'),
    $checked = $('input:checked');

if ($checked.length)
{
    var selector = $checked.map(function ()
    {
        return '.' + $(this).attr('rel');
    }).get().join('');

    $lis.hide().filter(selector).show().addClass("show");     
}
else
{
    $lis.show().removeClass("show");
}
});
  • 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-06-07T06:54:41+00:00Added an answer on June 7, 2026 at 6:54 am

    Try this:

    EDIT: I’ve modified the method to be able to filter exclusively. This way, you’ll be able to filter by, say, shirts and trousers that are green or pink.

    $(function(){
        $('div.tags').delegate('input[type=checkbox]', 'change', function()
        {
            var $lis = $('.results > li'),
                $types = $('.filter-grp-type input:checked'),
                $colors = $('.filter-grp-color input:checked');
    
            if ($types.length)
            {
                var selector = $types.map(function ()
                {
                    return '.' + $(this).attr('rel');
                }).get().join(', ');
    
                $lis.hide().filter(selector).show();     
            }
            else
            {
                $lis.show();
            }
    
            $lis = $lis.filter(":visible");
    
            if ($colors.length)
            {
                var selector = $colors.map(function ()
                {
                    return '.' + $(this).attr('rel');
                }).get().join(', ');
    
                $lis.hide().filter(selector).show();     
            }
        });
    })
    

    When you were building up your “selector” string, you were just concatenating it. jQuery will then only filter those items which have ALL the classes in your selector.

    I agree with David Thomas. Rather make the selection of clothing type a mutually exclusive one, i.e. radio buttons.

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

Sidebar

Related Questions

I am trying to get synonyms working correctly, I want to map floor locker
I have 2 equal-length lists and I am trying to get scalar product of
I am trying to add a product to my DB, I need to get
So i am trying get 2 div-containers which both should contain centered text (Both
I'm trying to get a collection of selections but filtered on the parent product's
I am trying to get a product matching some custom parameters. So I have
I am trying to write a RSpec before filter to log a user in.
Trying to get the Product Version attribute from loaded DLLs. For example, my System.Web.dll
i am trying to get the 'cross product' of two vectors. these two vectors
I'm trying to create a filter form that user selects dates and sources. The

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.