I have a table that displays all classes available. The TR ID for each class is the class provider+grade level (Example: 8th grade Virtual class would be “Virtual8”). I then have a ‘Provider’ combo box, ‘Grade’ combo box, and ‘Class Title’ text box. When you click ‘Display’ it should hide all TRs, show TRs that display the correct ‘Provider’+’Grade’ ID, and then hide any TD’s parent(tr) that does not contain the class search.
Currently the class title search does nothing at all it appears.
I know this is very confusing, and there is probably an easier way to do it. Any suggestions would be greatly appreciated. If I leave the ‘Class Title’ box blank and search just for provider and grade level, the form works fine; however, adding a class title in the search does nothing.
The Code:
<script src="jquery.missing.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#display").click(function() {
$('tr[id^="Independent"]').hide();
$('tr[id^="Virtual"]').hide();
$('tr[id^="Innovative"]').hide();
$('tr[id^="Lincoln"]').hide();
$('tr[id^="Missouri"]').hide();
$('tr[id^="Calvert"]').hide();
var result = $('#theprovider').val() + $('#thegrade').val();
$('tr[id*="' + result + '"]').show();
var search = $('#searchclass').val();
$('td:missing("' + search + '")').closest('tr').hide();
});
});
</script>
Missing.js Code (provided by Darcy Clarke):
$.expr[':'].missing = function(elem, index, match) {
return (elem.textContent || elem.innerText || Sizzle.getText([elem]) || "").indexOf(match[3]) == -1;
}
You have to escape doubt quotes only if they are used inside enclosing double quotes, same applies to single quotes too.
Instead of
missingyou can try using combination ofnotandcontainslike this.