The issue was that the predicate you had logically constructed was a disjunction (a combination of "or"s). As such, when you checked "Male" and "Active" the script showed all rows that contained males OR active users, which were all of them in your example.
@Rajaprabhu Aravindasamy's answer is fine, but requires multiple passes over your table's rows. If you want, you could take a more functional approach and construct a predicate that will allow you to make a single pass over them:
http://jsfiddle.net/3XhCa/10/
function tautology() {
return true;
}
function makePredicate(text, column) {
return function(row) {
return -1 !== $(row).children('td:eq(' + column + ')').text().indexOf(text);
};
}
var isMale = makePredicate('Male', 2);
var isPopular = makePredicate('Yes', 3);
var isActive = makePredicate('Yes', 4);
function conjoin(f, g) {
return function (row) {
return f(row) && g(row);
};
};
//a check box has been checked
$(':checkbox').change(function() {
var isVisible = tautology;
//are there no check boxes selected?
if ($('input:checkbox:checked').length > 0) {
//show only rows needed to be show
if ($('#male').is(':checked')) {
isVisible = conjoin(isVisible, isMale);
}
if ($('#popular').is(':checked')) {
isVisible = conjoin(isVisible, isPopular);
}
if ($('#active').is(':checked')) {
isVisible = conjoin(isVisible, isActive);
}
$('tbody > tr').each(function() {
$(this).toggle(isVisible(this));
});
} else {
//there are no check boxes selected, show all rows
$('tr').show();
}
});