/    Sign up×
Community /Pin to ProfileBookmark

Java Script to access table cell data

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>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@pyroMay 08.2003 — You can use getElementById("someid").innerHTML, something like this:

&lt;script language="javascript" type="text/javascript"&gt;
function getText() {
firstval = document.getElementById("firstcell").innerHTML;
alert (firstval);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td id="firstcell"&gt;test&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;a href="#" onclick="getText(); return false;"&gt;Show text in cell one&lt;/a&gt;
Copy linkTweet thisAlerts:
@clydeauthorMay 08.2003 — I will give it a try
×

Success!

Help @clyde spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...