Click to See Complete Forum and Search --> : Java Script to access table cell data


clyde
05-08-2003, 09:10 AM
Please refer to the code below in relationship to this problem.

How Can I extract the value of cell data From a table. When the cell data is defined as a Input=Text I can do it.

If I load the table cells with variables I cannot access the data.

If this is possible Please Help.



<!-- *** ADD CART ***-->
function add_cart (obj,index)
{
alert("got to add cart");
var qindex = eval('document.Iform.Mfgqty_'+index);
alert(qindex.value);

window.open("/infcgilibp/isl550.pgm?mfgno=/%mfgnum%/&mfgdes=/%mfgdesc%/&mfgqty="+qindex.value,
"Iform1", "scrollbars,status,top=10,left=70,height=500,width=760");
return;
}



<tr>
<td><FONT size="-1"><a name="/%Mfgx%/">/%Mfg%/</a></FONT></td>
<td><FONT size="-1">/%Mfgdesc%/</FONT></td>
<td><FONT size="-1">/%Mfgnum%/</FONT></td>
<td><FONT size="-1">/%Mfgprice%/</FONT></td>
<td><FONT size="-1"><INPUT size="4" type="text" maxlength="4" name="/%Mfgqty%/"></FONT></td>
<td valign="middle" align="center"><FONT size="-1"><A href="javascript:add_cart(/%xxx%/);">Add</A></td>
</tr>

pyro
05-08-2003, 09:30 AM
You can use getElementById("someid").innerHTML, something like this:

<script language="javascript" type="text/javascript">
function getText() {
firstval = document.getElementById("firstcell").innerHTML;
alert (firstval);
}
</script>
</head>
<body>
<table>
<tr>
<td id="firstcell">test</td>
</tr>
</table>
<a href="#" onclick="getText(); return false;">Show text in cell one</a>

clyde
05-08-2003, 10:04 AM
I will give it a try