...

View Full Version : read contents of table cell



nikko50
05-30-2009, 01:34 AM
Hi all. Is it possible to read the contents of a table cell. I have the below table and would like extract the value of the first cell. The first cell will always be a hyperlink so I guess I only need the contents between the "<A>" tags. So the first row should return ""434235". How can I do this.


<table width=100% align=center border=0 cellspacing=2 cellpadding=2>
<tr>
<td align=center><font size="1" >
<a href="Display?new=00328">434235</a></font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">john
riley</font>
</td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">0008</font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">FARMLAND</font></td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">03-02-2009</font></td>
<td align=center><font size=-1 face="Verdana,Arial,Geneva">
<input type=text size=10 maxlength=10 name="new" value="05-11-2009" ></font></td>
</tr>

<tr>
<td align=center><font size="1" >
<a href="Display?new=07056">2233556</a></font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">JEFF
COOK</font>
</td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">0001</font></td>
<td align=left><font size=1 face="Verdana,Arial,Geneva">NEW JERSEY&nbsp; </font></td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">02-02-2009</font></td>
<td align=center><font size=-1 face="Verdana,Arial,Geneva">
<input type=text size=10 maxlength=10 name="new" value="06-08-2009" ></font></td>
</tr>

<tr>
<td align=center><font size="1" >
<a href="Display?new=07605">232344</a></font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">FRANK
COOK</font>
</td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">0025</font></td>
<td align=left><font size=1 face="Verdana,Arial,Geneva">ROANOKE </font></td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">06-27-2011</font></td>
<td align=center><font size=-1 face="Verdana,Arial,Geneva">
<input type=text size=10 maxlength=10 name="new" value="08-10-2009" ></font></td>
</tr>

</table>

JygzIsHere
05-30-2009, 03:57 AM
Hi, Try This One:





<table id='tbl' width=100% align=center border=0 cellspacing=2 cellpadding=2>
<tr>
<td align=center><font size="1" >
<a href="Display?new=00328">434235</a></font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">john
riley</font>
</td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">0008</font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">FARMLAND</font></td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">03-02-2009</font></td>
<td align=center><font size=-1 face="Verdana,Arial,Geneva">
<input type=text size=10 maxlength=10 name="new" value="05-11-2009" ></font></td>
</tr>

<tr>
<td align=center><font size="1" >
<a href="Display?new=07056">2233556</a></font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">JEFF
COOK</font>
</td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">0001</font></td>
<td align=left><font size=1 face="Verdana,Arial,Geneva">NEW JERSEY&nbsp; </font></td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">02-02-2009</font></td>
<td align=center><font size=-1 face="Verdana,Arial,Geneva">
<input type=text size=10 maxlength=10 name="new" value="06-08-2009" ></font></td>
</tr>

<tr>
<td align=center><font size="1" >
<a href="Display?new=07605">232344</a></font></td>
<td align=left><font size="1" face="Verdana,Arial,Geneva">FRANK
COOK</font>
</td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">0025</font></td>
<td align=left><font size=1 face="Verdana,Arial,Geneva">ROANOKE </font></td>
<td align=center><font size=1 face="Verdana,Arial,Geneva">06-27-2011</font></td>
<td align=center><font size=-1 face="Verdana,Arial,Geneva">
<input type=text size=10 maxlength=10 name="new" value="08-10-2009" ></font></td>
</tr>

</table>

<script type='text/javascript' language='javascript'>
var objTbl = document.getElementById('tbl');
var data = "";

for (i=0; i < objTbl.rows.length; i++)
{
var tmpCell = objTbl.rows[i].cells[0];
var tmpContent;

if (tmpCell.innerText)
tmpContent = tmpCell.innerText;
else
tmpContent = tmpCell.textContent;

if (tmpContent != "undefined")
{
data += "Row " + (i+1) + " Cell 1 = " + tmpContent + "\n\r";
}
}

alert (data);

</script>

JygzIsHere
05-30-2009, 04:05 AM
<script type='text/javascript' language='javascript'>
var objTbl = document.getElementById('tbl');
var data = "";

for (i=0; i < objTbl.rows.length; i++)
{
var tmpCell = objTbl.rows[i].cells[0];
var tmpContent;

if (tmpCell.innerText)
tmpContent = tmpCell.innerText;
else
tmpContent = tmpCell.textContent;

if (tmpContent != "undefined")
{
data += "Row " + (i+1) + " Cell 1 = " + tmpContent + "\n\r";
}
}

alert (data);

</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum