Get Table Cell Value using Javascript

Discussion in 'ASP .Net' started by =?Utf-8?B?Qw==?=, Apr 23, 2007.

  1. How do I get the text from my cell e..g. <td>Test Text</td>



    var elTableCells = elTableRow.getElementsByTagName("td");

    alert(elTableCells[0].innerText);
     
    =?Utf-8?B?Qw==?=, Apr 23, 2007
    #1
    1. Advertisements

  2. The easiest way to get a particular cell is to give it an ID, of course. You
    then do not have to play any games. Even if you are binding, you can do this
    by adding IDs during the data binding event. You can add IDs and even add
    events if a person clicks a cell. It takes slightly longer to render, but it
    is easier than searching through the haystack later.

    If this is not an option, you will have to go through finding the table and
    then iterating through rows to find the particular cell. This tutorial shows
    how to create a table, but the basic process of iterating through cells is
    the same:
    http://developer.mozilla.org/en/docs/Traversing_an_HTML_table_with_JavaScript_and_DOM_Interfaces

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com

    *********************************************
    Think outside the box!
    *********************************************
    "C" <> wrote in message
    news:...
    > How do I get the text from my cell e..g. <td>Test Text</td>
    >
    >
    >
    > var elTableCells = elTableRow.getElementsByTagName("td");
    >
    > alert(elTableCells[0].innerText);
    >
     
    Cowboy \(Gregory A. Beamer\), Apr 23, 2007
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phillip Roncoroni
    Replies:
    14
    Views:
    1,245
    Toby A Inkster
    Apr 5, 2004
  2. =?Utf-8?B?Qw==?=

    Get Table Cell value using Javascript

    =?Utf-8?B?Qw==?=, Apr 23, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    86,133
    oceans_ripple_light
    Jul 25, 2012
  3. yukatan

    get a table cell value

    yukatan, Nov 6, 2003, in forum: Javascript
    Replies:
    2
    Views:
    313
    Lasse Reichstein Nielsen
    Nov 6, 2003
  4. harry

    Get 2nd cell value from table row?

    harry, Jul 22, 2004, in forum: Javascript
    Replies:
    2
    Views:
    317
    Mick White
    Jul 22, 2004
  5. Sunny

    get Table cell value

    Sunny, Oct 20, 2008, in forum: Javascript
    Replies:
    3
    Views:
    639
    Martin Honnen
    Oct 20, 2008
Loading...

Share This Page