PDA

View Full Version : How to read contents of a Table



dfx
06-20-2005, 11:06 AM
Hi.

I needs to read, at client side, the text content of a row of of a small table as the following using a javascript function having as parameter the Id (i.e. 89, 7659,...):

<TABLE Id="MyTable" name="Mytable">
<TR>
<TD Id=""89">Donald Duck</TD>
</TR>
<TR>
<TD Id=""7659">Donald Duck</TD>
</TR>
</TABLE>

How can I do it?
Other suggestions to manage, al client side, small indexed tables are welcome.

Thanks for any and all guidence anyone can give in this matter.

jscheuer1
06-20-2005, 05:39 PM
Values for the attribute id that begin with numbers often do not work in many situations. Also, the way you have it (with two double quotes followed by the id and then another double quote), would be read by most browsers as no id. Is there any way that they could be changed to, say:
<TABLE Id="MyTable" name="Mytable">
<TR>
<TD Id="a89">Donald Duck</TD>
</TR>
<TR>
<TD Id="a7659">Donald Duck</TD>
</TR>
</TABLE>so that they would at least be valid id's?

If so, you could then have their values available like so:

document.getElementById('a89').innerHTML

for whatever use you have in mind, ex:
alert(document.getElementById('a89').innerHTML)