Filter Results using checkboxes
<p>I am using the following code to filter my results by using checkboxes. It displays the results which have checked items in common:</p>

<pre><code>$('input').change(function() {

    var room_array = new Array(),
        loc_array = new Array();
    $('.br').each(function() {
        if ($(this).is(':checked')) {
            room_array.push($(this).data('bedrooms'));
        }
    });
    $('.loc').each(function() {
        if ($(this).is(':checked')) {
            loc_array.push($(this).data('location'));
        }
    });
    //console.log(loc_array, room_array);
    $('li').each(function() {
        if ($.inArray($(this).data('location'), loc_array) &gt; -1 &amp;&amp; $.inArray($(this).data('bedrooms'), room_array) &gt; -1) {
            $(this).show();
        } else {
            $(this).hide();
        }
    });
});
</code></pre>



<pre><code>&lt;input data-bedrooms="1" class="br" type="checkbox"&gt;1 bedroom&lt;br&gt;
&lt;input data-bedrooms="2" class="br" type="checkbox"&gt;2 bedrooms&lt;br&gt;
&lt;input data-bedrooms="3" class="br" type="checkbox"&gt;3 bedrooms&lt;br&gt;&lt;br&gt;

&lt;input data-location="london" class="loc" type="checkbox"&gt;london&lt;br&gt;
&lt;input data-location="new-york" class="loc" type="checkbox"&gt;new york&lt;br&gt;
&lt;input data-location="paris" class="loc" type="checkbox"&gt;paris&lt;br&gt;&lt;br&gt;    

&lt;ul&gt;
    &lt;li data-bedrooms="1"  data-location="paris"&gt;1 bedroom apartment paris&lt;/li&gt;
    &lt;li data-bedrooms="1" data-location="paris"&gt;1 bedroom apartment&lt;/li&gt;
        &lt;! -- similar combinations --&gt;
    &lt;li data-bedrooms="2" data-location="new-york"&gt;2 bedroom apartment new yor&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p><strong><a href="http://jsfiddle.net/YEtgM/13/" rel="nofollow">JSFiddle</a></strong></p>

<p>The problem is that when only 1 type of checkbox is selected, the results for that checkbox don't display.</p>

<p>However, I want to allow the selection of only one type, e.g. either the number of bedrooms or the location. How can I achieve this?</p>
