How to search (using javascript) an already loaded table for a value ?

How to search (using javascript) an already loaded table for a value ?

NefariousNefarious Posts: 3Questions: 2Answers: 0

Hi -

So when my page loads, I have a datatable that reads in data from an sql database table and displays it in a table on the page.

What I would like to do is be able (using javascript) - to be able to find the value of one column given a value in another column. So for example, if you had a table that had a column called "ID" and another called "email". To be able to get the value of the "email "column after locating (or not) the "ID" column. So I dont want to filter the table visually, just get a value of one column based on the value of antother column.

For example, the page loads a list of vets (name, details inclucing email.) I have a button that reads "Send Referal" which will email the vet with a referal request. So I feed the function a "vetname" and it iterates through the table and returns the "email" column that matches the "vetname" column.

Most of the search examples I have come across, either simulate a user entering data into the seach area or returning values after user clicks a table (event driven.)

I realise that I could just re-query the database for the information, but it seems unnessesary as we have already loaded the same information into the table.

Many thanks..
Paul.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You could use filter() for that - that filters the table's data based on some criteria, but doesn't affect the display of the table. There are some examples at the bottom of the reference page that should get you going,

    Colin

  • NefariousNefarious Posts: 3Questions: 2Answers: 0

    ok ty Colin,

    Cheers..

Sign In or Register to comment.