Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question childObjects of a table/tbody

    Ok. I have to learn this sometime I guess, lol.

    I want to cycle through each row of a table and perform a function on it. In the past, I've simply given each row an ID number, like (id="row1", id="row2") etc. I now have a huge table, and that would be tiresome.

    I need to find a way to use some method of cycling through each table's rows and performing a function on it. I thought something like "theTable.childObjects" would do the trick, but I'm not sure what I'm doing. If at all possible, can all of the child objects of a <TBODY> tag be cycled through instead of an entire table? If not, that's ok. I just need *some* method of doing this other than the row numeration.

    HELP!

    Thanks in advance.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    <table>
      <tbody id="blah">
        <tr><td></td></tr>
        <tr><td></td></tr>
        <tr><td></td></tr>
      </tbody>
    </table>
    ...
    var rows = document.getElementById('blah').getElementsByTagName("TR");
    for (var i=0; i<rows.length; i++)
    {
      alert(rows[i]);
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    class..?

    ok.... hmm... that worked great except...


    how do i get the CSS class name of an object? i.e.:

    <TR class=scheduleES>...

    in the above script, i tried rows[i].class but it didnt work. any help?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    rows[i].className
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    very sorry. i didn't search the MSDN 'object' database before posting

    thanks for all your help!


  •  

    Posting Permissions

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