Get 2nd cell value from table row?

H

harry

I want to be able to read the value from the 2nd cell in a table row which
contains 5 cells.

The row ID is 'tr2' & I can get the row object using -

var x = document.getElementById('tr2');

How do I get hold of an individual cell's value?

Any links to good web sites showing how to traverse DOM objects?

thanks

harry
 
G

Gaetano Bigliardi

harry said:
I want to be able to read the value from the 2nd cell in a table row which
contains 5 cells.

The row ID is 'tr2' & I can get the row object using -

var x = document.getElementById('tr2');

Try this:

var text = x.cells[1].innerHTML;


Gaetano
 
M

Mick White

harry said:
I want to be able to read the value from the 2nd cell in a table row which
contains 5 cells.

The row ID is 'tr2' & I can get the row object using -

var x = document.getElementById('tr2');

How do I get hold of an individual cell's value?

var x = document.getElementById('tr2')
var y= x.getElementsByTagName("TD")
var z=y.item(1).firstChild.data;

Mick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top