using getobjectbyname javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eldad
    New Member
    • Dec 2009
    • 3

    using getobjectbyname javascript

    hi
    i have a table let say 10x10
    how can i go to each td and check the innerhtml value without giving an id
    for each td
    i canot give an id for each td because the table is build by a function
    thank u
    ( i am trying to build a cross puzzel with a javascript code and i nedd to know the value of each td)
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    how can i go to each td and check the innerhtml value without giving an id for each td
    loop through all cells of that table, returned by getElementsByTa gName()

    i canot give an id for each td because the table is build by a function
    that is a lame excuse. although I admit, generating IDs is not very convenient.

    a simple example in PHP could look like
    Code:
    echo '<td id="cell' . $count++ . '">cell content</td>';

    Comment

    • eldad
      New Member
      • Dec 2009
      • 3

      #3
      thanks but can u be more specifice with the answers is javascript
      not php
      what do u meen by loop what kind of loop

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        what do u meen by loop what kind of loop
        whatever you like. for, while, do … while, pick one of them.

        can u be more specifice with the answers is javascript
        what kind of more specific? the principle of creating the IDs ain’t much different in other languages, including JavaScript.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          If you're going to use elem.getElement sByTagName("td" ) (elem being the table or tbody element), there's no need to set any IDs. Check out a simple JavaScript tutorial on the different types of loops (see the off-site links thread for some links). If you're familiar with a C-style language, JavaScript loops should be pretty easy to pick up.

          Comment

          • eldad
            New Member
            • Dec 2009
            • 3

            #6
            thank u very much u where very helpfull

            Comment

            Working...