title: Loop through HTML table with Javascript
body: <p>I need to loop over a HTML table and pick up values in a specific way with javascript.</p>
  
  <p>My table looks like this:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;td class="name"&gt;Henk&lt;/td&gt;
          &lt;td class="day"&gt;tuesday&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td id="number_2"&gt;667&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="name"&gt;Jill&lt;/td&gt;
          &lt;td class="day"&gt;monday&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td id="number_5"&gt;77&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="name"&gt;Joe&lt;/td&gt;
          &lt;td class="day"&gt;wednesday&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td id="number_1"&gt;112&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="name"&gt;Henk&lt;/td&gt;
          &lt;td class="day"&gt;monday&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td id="number_3"&gt;345&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="name"&gt;Joe&lt;/td&gt;
          &lt;td class="day"&gt;friday&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;text&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td id="number_4"&gt;332&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>What I need to collect is:</p>
  
  <pre><code> Henk,345,667,0,0,0
   Jill,77,0,0,0,0
   Joe,0,0,112,0,332
  </code></pre>
  
  <p>The names need to be collected one time only, and after that pick up the days that this person has a number listed in the number cell, will be sorted by weekdays (monday-friday). The days that there are no numbers can be filled with a '0'.</p>
  
  <p>The table will be generated and can be of any length and in any specific order. So if I would refresh the page, the row-order can be changed (e.a. putting Jill,77 in the first row). The table and contents are generated with PHP, but the number-cell is filled by javascript. After that a button will be pressed to export the data with javascript. This will then be used as input for a csv file.
  In the export, the 'text' values are ignored.</p>
  
  <p>I can't seem to get the correct loop. How can I accomplish this with javascript?</p>
  
  <p>Edit: I have no example code as everything I tried failed to deliver the right outcome.</p>