Advanced Search

Results 1 to 2 of 2

Thread: How to read contents of a Table

  1. #1
    Join Date
    Jun 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to read contents of a Table

    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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,690
    Thanks
    43
    Thanked 3,129 Times in 3,095 Posts
    Blog Entries
    12

    Default

    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:
    Code:
    <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:
    Code:
    alert(document.getElementById('a89').innerHTML)
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •