Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to extract the cell value from row ?

Status
Not open for further replies.

quarkX

Programmer
Dec 9, 2003
1
US
Hello,
How to extract the cell value from a row? I have the row
id but when i try something like this
...
document.getElemntById("rowID").cells[0].value
....
It doesn't work.

Thanks!
 
Try
Code:
document.getElemntById("rowID").cells[0].innerHTML
 
You could also use firstChild.nodeValue:

Code:
<HTML>
<HEAD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

	function getContents(cellID)
	{
		var myCellObj = document.getElementById(cellID);
		alert(myCellObj.firstChild.nodeValue);
	}

//-->
</SCRIPT>

</HEAD>
<BODY>

<TABLE BORDER=&quot;1&quot;>
<TR>
	<TD ID=&quot;c1r1&quot;>abc</TD>
	<TD ID=&quot;c2r1&quot;>def</TD>
	<TD ID=&quot;c3r1&quot;>ghi</TD>
</TR>
<TR>
	<TD ID=&quot;c1r2&quot;>jkl</TD>
	<TD ID=&quot;c2r2&quot;>mno</TD>
	<TD ID=&quot;c3r2&quot;>pqr</TD>
</TR>
<TR>
	<TD ID=&quot;c1r3&quot;>stu</TD>
	<TD ID=&quot;c2r3&quot;>vwx</TD>
	<TD ID=&quot;c3r3&quot;>yz</TD>
</TR>
</TABLE>

<BR>
Click <A HREF=&quot;javascript:getContents('c2r2');&quot;>here</A> to see the contents of cell c2r2...

</BODY>
</HTML>

Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top