Filtering a table on number values

Filtering a table on number values

I have the following code I am using to filter some table data...

  1. $(".filter").keyup(function() {
  2. $("tr:hidden").show();
  3. $("td.gradeName:not(:contains( '" +  $("#filter_grade").val() + "'))").parent().hide();
  4. var solidMin = $("#filter_solids").val() - $("#filter_solids_pm").val();
  5. var solidMax = $("#filter_solids").val() + $("#filter_solids_pm").val();
  6. $("td.solids:not(:contains('" +  $("#filter_solids").val() + "'))").parent().hide();
  7. });

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...