I have pictures hiding and showing based on a multiple dropdown menu selection. I am trying to have the 2 and possible more dropdown menus working together to refine a search.
If I select an item in the first dropdown, I would like to apply the second filter and so on with any additional dropdown.
I need some help with the jquery. My current problem is the 2nd filter never kicks in. It gets overwritten and resets the filter. If possible, I would like to add a 3rd filter to narrow the search even more to find exactly what I am looking for. Here is some sample code..
$('select').change(function(){
var current = $(this).attr('value');
if(current == 'all'){
$('#FilterContainer').children('div.all').show();
}
else {
$('#FilterContainer').children('div:not(.' + current + ')').hide();
$('#FilterContainer').children('div.' + current).show();
}
return false;
})
HTML
<p>Filter: </p>
<select class="filterby">
<option value="all"><h5>Show All</h5></option>
<option value="1"><h5>One</h5></option>
<option value="2"><h5>Two</h5></option>
<option value="3"><h5>Three</h5></option>
</select>
<p>Location: </p>
<select class="filterby">
<option value="all"><h5>All Locations</h5></option>
<option value="nj"><h5>NJ</h5></option>
<option value="ny"><h5>NY</h5></option>
<option value="pa"><h5>PA</h5></option>
</select>
<div id="FilterContainer">
<div class="all 1 nj">Test One NJ</div>
<div class="all 1 ny">Test One NY</div>
<div class="all 1 pa">Test One PA</div>
<div class="all 2 nj">Test Two NJ</div>
<div class="all 2 ny">Test Two NY</div>
<div class="all 2 pa">Test Two PA</div>
<div class="all 3 nj">Test Three NJ</div>
<div class="all 3 ny">Test Three NY</div>
<div class="all 3 pa">Test Three PA</div>
<div class="all 1 nj">Test One NJ</div>
<div class="all 1 pa">Test One PA</div>
<div class="all 1 pa">Test One PA</div>
<div class="all 2 nj">Test Two NJ</div>
<div class="all 2 ny">Test Two NY</div>
<div class="all 2 ny">Test Two NY</div>