get table row contents
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adam_M
Posted On:   Monday, June 6, 2005 11:57 PM

I am trying to make a javascript search. I have one page that consists of a table. I would like to be able to search the page for a term and if that term appears in a certain row of the table, it will return the entire table row.

i.e. if I search for "hello" and there is a row in the table with the contents "hello my name is adam", it will return then entire row.

ANy help would be appreciated! thanks in advance.

Re: get table row contents

Posted By:   Eric_k  
Posted On:   Tuesday, June 7, 2005 03:17 PM

Use the following function to display cell contents:

function search(tbl, val){
if(val.length<1)
return;
for (r=0;r len=tbl.rows[r].cells.length;
for(c=0; c text = tbl.rows[r].cells[c].innerText;
if(text.indexOf(val)>-1)
alert(text);
}
}
}


Your table should have an id,e.g. "myTable" and be enclosed in a form that will go like this:





You can find some DHTML examples handling table rows at

http://www.geocities.com/eric6930/dhtml.html

About | Sitemap | Contact