Hi all,
The title might be a bit confusing, basically I'm trying to write up a script which will grab the selected values from a drop down form, and hide li's if its class does not contain the values from the drop down form.. if that makes sense?? Each li has multiple classes..
Here's what I've got so far (sorry if it's crude):
FORM:
<form action="" name="filter" id="filter" method="post">
<select name="bedrooms">
<option value="">- Select Bedrooms -</option>
<option value="bed-1">1</option>
<option value="bed-2">2</option>
<option value="bed-3">3</option>
<option value="bed-4">4</option>
<option value="bed-5">5</option>
</select>
<select name="bathrooms">
<option value="">- Select Bathrooms -</option>
<option value="bath-1">1</option>
<option value="bath-2">2</option>
<option value="bath-3">3</option>
<option value="bath-4">4</option>
<option value="bath-5">5</option>
</select>
<select name="frontage">
<option value="">- Select Frontage Size -</option>
<option value="frontage-100">100</option>
<option value="frontage-200">200</option>
<option value="frontage-300">300</option>
<option value="frontage-400">400</option>
<option value="frontage-500">500</option>
</select>
<input type="submit" name="filter-submit" id="filter-submit" value="Go" />
</form>
JQuery:
$("#filter-submit").click(function() {
var foo = [];
$("#filter :selected").each(function(i, value){
foo[i] = $(value).val();
});
if (foo) {
$.each(foo, function(index, value){
if (value) {
//hide other objects based on "value"
//$("#portfolio li").hasClass();
};
});
};
return false;
});
Ok so where I'm stuck is how to hide all "#portfolio li"'s which don't have the class which is outputted as "value". I thought I could use hasClass but not sure how to reverse it.. if that makes sense? Any help would be appreciated :)