Hello i have a list of apartments and i need to filter them by type (eg studio, 1 bedroom, 2 bedroom . ) via checkboxes. You could see the demo at http://jsfiddle.net/YByCk/1/ I don't know how to make this if you select for example 1 Bedrooms and 2 Bedrooms to show results for 1 and 2 bedrooms if 1 is already checked. The problem is when you check second checkbox will show only last checkbox filter, won't keep also the other checkboxes selected.
//function count results after filter
function divcount()
{
var resCount = $('.listing').filter(":visible").size();
//alert(resCount)
$("#contResults").html(resCount + ' results');
}
//bedrooms filter
$("#Studio").click(function(){
if($("#Studio").is(':checked'))
{
$('.listing[bedrooms!="Studio"]').hide();
divcount();
}
if(!$("#Studio").is(':checked'))
{
$('.listing[bedrooms!="Studio"]').show();
divcount();
}
});
$("#1B").click(function(){
if($("#1B").is(':checked'))
{
$('.listing[bedrooms!="1 Bedroom"]').hide();
divcount();
}
if(!$("#1B").is(':checked'))
{
$('.listing[bedrooms!="1 Bedroom"]').show();
divcount();
}
});
$("#2B").click(function(){
if($("#2B").is(':checked'))
{
$('.listing[bedrooms!="2 Bedroom"]').hide();
divcount();
}
if(!$("#2B").is(':checked'))
{
$('.listing[bedrooms!="2 Bedroom"]').show();
divcount();
}
});
$("#3B").click(function(){
if($("#3B").is(':checked'))
{
$('.listing[bedrooms!="3 Bedroom"]').hide();
divcount();
}
if(!$("#3B").is(':checked'))
{
$('.listing[bedrooms!="3 Bedroom"]').show();
divcount();
}
});
$("#4B").click(function(){
if($("#4B").is(':checked'))
{
$('.listing[bedrooms!="4 Bedroom"]').hide();
divcount();
}
if(!$("#4B").is(':checked'))
{
$('.listing[bedrooms!="4 Bedroom"]').show();
divcount();
}
});
$("#5B").click(function(){
if($("#5B").is(':checked'))
{
$('.listing[bedrooms!="5 Bedroom"]').hide();
divcount();
}
if(!$("#5B").is(':checked'))
{
$('.listing[bedrooms!="5 Bedroom"]').show();
divcount();
}
});
any ideas?
Thank you