Filtering a table on number values
I have the following code I am using to filter some table data...
- $(".filter").keyup(function() {
- $("tr:hidden").show();
- $("td.gradeName:not(:contains( '" + $("#filter_grade").val() + "'))").parent().hide();
- var solidMin = $("#filter_solids").val() - $("#filter_solids_pm").val();
- var solidMax = $("#filter_solids").val() + $("#filter_solids_pm").val();
- $("td.solids:not(:contains('" + $("#filter_solids").val() + "'))").parent().hide();
- });
There are text fields with the IDs filter_grade, filter_solids and filter_solids_pm.
The first part dealing with grade names works perfectly, you type in the box and the table filters. The second part has stumped me though. the filter_solids_pm field is used for a "Plus / Minus" type of filter so if 50 is entered into the filter_solids field and 2 into the filter_solids_pm field then it need to filter out all rows with a value outside the range 48 to 52.
As I understand it jQuery has no numeric comparison so I will need javascript to achieve this (hence the two var's I have created to start off) but I have no idea where to go from here...