Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Refer to a table row using a variable?

Thread Tools

Refer to a table row using a variable?
Posts: n/a
Hi, I hope someone can help me with what is probably quite an easy

I need to store a string in a variable, and then use that variable to
refer to a table row. For example:

var row = 'row10';

My row is defined as:

<tr id='row10'>

If I use "'white' then it works, but if I
use the variable then it doesn't. I have tried it with and without
square brackets. What I am I doing wrong?


Reply With Quote
Martin Honnen
Posts: n/a
      01-14-2006 Removed) wrote:

> var row = 'row10';

> My row is defined as:
> <tr id='row10'>

Have you never heard about
var element = document.getElementById(row);
then? That is the main way in the W3C DOM to access an element by the
value of its id attribute, whether that is a tr element or just about
any other element in a HTML document.


Martin Honnen
Reply With Quote
Posts: n/a
Thank you. I had never heard of that, but it's working now.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting table row in table grid using ASP.NET MVC wxl ASP .Net 2 07-06-2009 09:50 PM
row bottom border in inner table not matching up with row border in outer table phl HTML 1 06-08-2006 03:43 PM
ie6 Insert Row at specific Row Index of Table Giggle Girl Javascript 18 02-07-2006 07:54 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Can center row in three row table take up remaining space? Anon HTML 2 03-18-2005 08:35 AM