Filtering table rows with Jquery
<p>I have a table showing registered users and the rows of this table can be filtered according to Status (active/inactive users or both) or User Type (admin/user or both). In order to make sure all of the table rows are filtered according to both criteria, I have PHP generate a 'info' attribute for each table row. Info can be one of four things:</p>

<ul>
<li>Active Admin </li>
<li>Active User</li>
<li>Inactive Admin</li>
<li>Inactive User</li>
</ul>

<p>This made it easy to filter out the user rows according to the options selected in the two filter drop-downs. </p>

<p>What I'm trying to figure out is how to filter them when <strong>Both</strong> is selected for one of the filter drop-downs--I know there's a more efficient way to do this than running six if statements every time one of the drop-downs is changed. </p>

<p>Here's my code: </p>

<pre><code>function toggleAll(){
    var selectedString = $('#userStatusDropDown').val() + ' ' + $('#userTypeDropDown').val();
    switch (selectedString){
        case 'Both Both':
            $('#tableUsers tr').show();
            break;

        default:
            $('#tableUsers tr:gt(1)').hide();
            $('#tableUsers tr[info="'+selectedString+'"]').show();
    }
}


$(document).ready(function(){   
        toggleAll();

        // admin/user drop down changes
        $('#userTypeDropDown').change(function(){
            toggleAll();
        });

        // active/inactive drop down changed
        $('#userStatusDropDown').change(function(){
            toggleAll();
        });
});
</code></pre>
