title: Convert HTML Table to JSON with Selectboxes
body: <p>I have the following table, which contains selectboxes, and I want to create a JSON string. 
  I tried several code snippets but none gave me a correct output.
  The output I want to have should be like:</p>
  
  <pre><code>id[0]: start time: 12:34;end time: 15:00
  id[1]: start time: 18:14;end time: 18:17
  </code></pre>
  
  <p>etc</p>
  
  <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script language="Javascript"&gt;
  
  function addRowEntry(tableID){
          var table = document.getElementById(tableID);
          var rowCount = table.rows.length;
          var row = table.insertRow(rowCount);
          var colCount = table.rows[1].cells.length;
          for(var i=0; i&lt;colCount; i++) {
              var newcell = row.insertCell(i);
              newcell.innerHTML = table.rows[1].cells[i].innerHTML;
          }
        }
  
  
  
  &lt;/script&gt;
  
  &lt;table id="dynTable" name="dynTable" border=0 width="200px"&gt; 
  &lt;thead&gt;
  &lt;tr height="50" id="header"&gt;
  
      &lt;td class="datacell"  align="center"&gt;Heure Start&lt;/td&gt;
  
      &lt;td class="datacell"  align="center"&gt;Min Start&lt;/td&gt;
      &lt;td class="datacell"  align="center"&gt;Heure End&lt;/td&gt;
  
      &lt;td class="datacell"  align="center"&gt;Min End&lt;/td&gt;
      &lt;td class="datacell" &gt;&lt;input type="button" value="Ajouter" name="add" id="add" style="width:50px" onclick="addRowEntry('dynTable');"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/thead&gt;    
  &lt;tbody&gt;
  &lt;tr id="TimeSel"&gt;
  &lt;td class="datacell" &gt;
      &lt;select id="openH" name="openH"&gt;
          &lt;option&gt;&lt;/option&gt;
          &lt;?php 
              for ($i=0;$i&lt;24;$i++) {
                  echo "&lt;option id=$i&gt;";
                  echo $i;
                  echo "&lt;/option&gt;";
              }
          ?&gt;
      &lt;/select&gt;
  &lt;/td&gt;
  
  &lt;td class="datacell" &gt;
      &lt;select id="openM" name="openM"&gt;
          &lt;option&gt;&lt;/option&gt;
          &lt;?php 
              for ($i=0;$i&lt;60;$i++) {
                  echo "&lt;option id=$i&gt;";
                  echo $i;
                  echo "&lt;/option&gt;";
              }
          ?&gt;
      &lt;/select&gt;
  &lt;/td&gt;
  &lt;td class="datacell" &gt;
      &lt;select name="closeH" id="closeH"&gt;
          &lt;option&gt;&lt;/option&gt;
          &lt;?php 
              for ($i=0;$i&lt;24;$i++) {
                  echo "&lt;option id=$i&gt;";
                  echo $i;
                  echo "&lt;/option&gt;";
              }
          ?&gt;
      &lt;/select&gt;
  &lt;/td&gt;
  
  &lt;td class="datacell" &gt;
      &lt;select name="closeM" id="closeM"&gt;
          &lt;option&gt;&lt;/option&gt;
          &lt;?php 
              for ($i=0;$i&lt;60;$i++) {
                  echo "&lt;option id=$i&gt;";
                  echo $i;
                  echo "&lt;/option&gt;";
              }
          ?&gt;
      &lt;/select&gt;
  &lt;/td&gt;
  &lt;/tbody&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
  
  &lt;input type="button" id="AddDateTime" name="AddDateTime" value="OK" onclick="tableToJson('dynTable');"&gt;&lt;/input&gt;
  </code></pre>
  
  <p>Edit: I deleted the include file. Was jused for some tests:</p>