This sounds specialized enough that you'll probably be writing the
code yourself. No problem, jQuery will help!

Basically, every time the contents of your text fields change, you'll
go through every row of the table, check specific cells, and if they
don't match the text (http://www.w3schools.com/jsref/jsref_match.asp)
from the text field, hide the row.  You'll need to set up the Drop-
down menus appropriately -- I would recommend that you have the Value
of the select Options be the index of the column.

So if your table is:
Name | Address | Ice Cream

Your select would contain:
<option value='0'>Name</option>
<option value='1'>Address</option>
<option value='2'>Ice Cream</option>

I started the index at 0, so I'll be using eq() in my code.  If I
started at 1, then I'd use nthChild:
http://docs.jquery.com/Core/eq  -- index starts at 0
http://docs.jquery.com/Selectors/nthChild  -- index starts at 1

You could generate these dropdowns automatically, but I won't get into
that here.

So the jQuery code that would get triggered on a "search" would look
something like this (untested code):

$('#myTable tbody tr').each( function () {
  var that = $(this); // save jQuery version of this

  var cellValueToConsider = that.find('td').eq(   $
('#firstDropDown').val() ).text();

  if (! cellValueToConsider.match( $('#firstSearchField').val() )  ) {
    that.parent().hide();
  }

   // repeat similar logic with #secondDropDown and #secondSearchField
  //   or generalize the code for an arbitrary number of search
fields.

});






On Oct 6, 10:50 am, bdee1 <[EMAIL PROTECTED]> wrote:
> I am looking for a simple way to filter the contents of a table.  to clarify
> - i would like to have a form at the top of an HTML table where i can select
> a field to filter on and then a textbox.  as i type in the textbox, the
> table's contents will change to display only rows where the selected field
> contains the search term.
>
> I actually found a plugin to do this (uiTableFilter), but i need to take ti
> one step further.  I need to have the ability to filter on more than one
> column.  I tried just having two forms on the page, each calling the
> uiTableFilter plugin, but as soon as you start typing in one box, it just
> cancels out the search from any of the other boxes.
>
> any suggestions here?
> --
> View this message in 
> context:http://www.nabble.com/simple-table-filtering--tp19839476s27240p198394...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to