Your logic is wrong; the last condition is being evaluated when it shouldn't be. (For instance: if y == 'All'
and also string.indexOf(m) >= 0
). Try this instead:
$('#files > option').each(function () {
var string = $(this).text();
var show;
if (y == 'All') {
show = m == 'All' || string.indexOf(m) >= 0;
} else if (m == 'All') {
show = string.indexOf(y) >= 0;
} else {
show = string.indexOf(y) >= 0 && string.indexOf(m) >= 0;
}
if (show) $(this).show();
else $(this).hide();
});