Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6530649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:46:53+00:00 2026-05-25T09:46:53+00:00

Basically what I’m trying to do is traverse a pretty big (>2k lines) table,

  • 0

Basically what I’m trying to do is traverse a pretty big (>2k lines) table, and get some information out of it with a javascript for loop.
The first iteration is doing exactly what I want, but that’s it. It doesn’t do anything else but return the first line and stops.

There is no error, and I’m at a loss after searching what could be the problem for several hours.

This is the script:

function start() {
    for (var i = 0; i < 100; i++){
        var tr = document.getElementsByTagName('tr')[i];

        var date = tr.getElementsByTagName('td')[1].innerHTML;
        var btime = tr.getElementsByTagName('td')[2].innerHTML;
        var etime = tr.getElementsByTagName('td')[3].innerHTML;
        var name = tr.getElementsByTagName('td')[5].innerHTML;
        var loc = tr.getElementsByTagName('td')[8].innerHTML;

        document.write(date + " " + name + " at " + loc + " from " + btime + " - " + etime);
    }
    document.write("End");
}

And what is returned is the following:

05-09-2011 Intro Module, Intro AI at AMC K01-222
from 10:00 - 12:00

And an example of the first table:

<table class="TableBody">
    <tr>
      <td class="dayCol">Ma</td>
      <td class="typeCol">05-09-2011</td>
      <td class="startCol">10:00</td>

      <td class="endCol">12:00</td>
      <td class="nameCol">3.1 Artificiële Intelligentie</td>
      <td class="nameCol">Intro Module, Intro AI</td>
      <td class="typeCol">H</td>
      <td class="staffCol">dr. D. Sent<br></td>
      <td class="roomCol"><a href="http://rooster.uva.nl/current_nl/showtimetable.aspx?type=reporturl&amp;idstring=830K01222">AMC K01-222</a><br></td>

      <td class="commentCol"> </td>
    </tr>
    <tr>
      <td class="dayCol">Ma</td>
      <td class="typeCol">05-09-2011</td>
      <td class="startCol">12:45</td>
      <td class="endCol">16:45</td>

      <td class="nameCol">3.1 Artificiële Intelligentie</td>
      <td class="nameCol">Zoeken</td>
      <td class="typeCol">H</td>
      <td class="staffCol">dr. N.B. Peek<br></td>
      <td class="roomCol"><a href="http://rooster.uva.nl/current_nl/showtimetable.aspx?type=reporturl&amp;idstring=830K01222">AMC K01-222</a><br></td>
      <td class="commentCol"> </td>

    </tr>
  </table>

So the first TR block is doing exactly as expected, but it isn’t going to the second block and further (using the i variable from the loop.

If I up the i variable in the third line manually, it does show the information of the TR block from put in number (e.g. if I change i to 15, it shows the 15th block info).

So I really don’t know what’s going wrong here. I would love if another pair of eyes could see what I am doing wrong here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:46:54+00:00Added an answer on May 25, 2026 at 9:46 am

    It is because of document.write which clears table so in the next iteration document.getElementsByTagName('tr') returns nothing.

    Instead of writing to the document using document.write you can append it into a dom element. Take a look at this.

    Working demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I'm using python to print out some information in the terminal and some
Basically i've a table for my users (it's nightclub website) and now i'm trying
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I have some code to check a specific directory to see if an
Basically I am trying to restart a service from a php web page. Here
Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
Basically, what I'm trying to create is a page of div tags, each has
Basically I'm attempting to add rows to a table, I need to do this
Basically what I'm trying to do is make a very simple vertical bullet projectile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.