title: Retrieving HTML Table Values
body: <p>I created a table and borrowed a javascript function from <a href="http://www.fourfront.us/blog/store-html-table-data-to-javascript-array" rel="nofollow noreferrer">http://www.fourfront.us/blog/store-html-table-data-to-javascript-array</a> to retrieve the contents of the table the way I wanted to. It almost works, but for some reason I cannot access the value that the user inputs.
  I have made a JS fiddle at <a href="http://jsfiddle.net/danielmdavies/4mu80x2L/1/" rel="nofollow noreferrer">http://jsfiddle.net/danielmdavies/4mu80x2L/1/</a> 
  The code is also posted below. If I use <code>"time_cutoff": $(tr).find('td:eq(2)').html()</code> instead of <code>"time_cutoff": $(tr).find('td:eq(2)').val(),</code> I get the html code that is correct I believe.</p>
  
  <p>This is the relevant html code:</p>
  
  <pre><code>&lt;table id="cycler_table"&gt;
      &lt;tr&gt;
          &lt;th&gt;Cycle Step&lt;/th&gt;
          &lt;th&gt;Mode&lt;/th&gt;
          &lt;th&gt;Time Cutoff&lt;/th&gt;
          &lt;th&gt;Voltage Cutoff&lt;/th&gt;
          &lt;th&gt;Current Cuttoff&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;1&lt;/td&gt;
          &lt;td&gt;
              &lt;select name='cyc_mode1'&gt;
                  &lt;option value='galvanostatic'&gt;Galvanostatic&lt;/option&gt;
                  &lt;option value='Potentiostatic'&gt;Potentiostatic&lt;/option&gt;
                  &lt;option name='rest'&gt;Rest&lt;/option&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='time_cutoff1' value='10'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='voltage_cutoff1' value='0'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='current_cutoff1' value='0'&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;2&lt;/td&gt;
          &lt;td&gt;
              &lt;select name='cyc_mode2'&gt;
                  &lt;option value='galvanostatic'&gt;Galvanostatic&lt;/option&gt;
                  &lt;option value='Potentiostatic'&gt;Potentiostatic&lt;/option&gt;
                  &lt;option name='rest'&gt;Rest&lt;/option&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='time_cutoff2' value='10'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='voltage_cutoff2' value='0'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='current_cutoff2' value='0'&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;3&lt;/td&gt;
          &lt;td&gt;
              &lt;select name='cyc_mode3'&gt;
                  &lt;option value='galvanostatic'&gt;Galvanostatic&lt;/option&gt;
                  &lt;option value='Potentiostatic'&gt;Potentiostatic&lt;/option&gt;
                  &lt;option name='rest'&gt;Rest&lt;/option&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='time_cutoff3' value='10'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='voltage_cutoff3' value='0'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='current_cutoff3' value='0'&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;4&lt;/td&gt;
          &lt;td&gt;
              &lt;select name='cyc_mode4'&gt;
                  &lt;option value='galvanostatic'&gt;Galvanostatic&lt;/option&gt;
                  &lt;option value='Potentiostatic'&gt;Potentiostatic&lt;/option&gt;
                  &lt;option name='rest'&gt;Rest&lt;/option&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='time_cutoff4' value='10'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='voltage_cutoff4' value='0'&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type='text' name='current_cutoff4' value='0'&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;textarea id="tbTableValuesArray" name="tblValuesArray" rows="10"&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  &lt;p id="cyc_confirm"&gt;Waiting for Properties to be Confirmed
      &lt;button onclick="storeAndShowTableValues()"&gt;Send the Setup&lt;/button&gt;
  </code></pre>
  
  <p>And the Javascript</p>
  
  <pre><code>$(document).ready(function () {
      console.log("ready!");
      storeAndShowTableValues();
  });
  
  
  function storeAndShowTableValues() {
      var TableData;
      TableData = storeTblValues();
      $('#tbTableValuesArray').val('TableData = \n' + print_r(TableData));
  }
  
  function storeTblValues() {
      var TableData = new Array();
  
      $('#cycler_table tr').each(function (row, tr) {
          TableData[row] = {
              "cyc_mode": $(tr).find('td').eq(1).val(),
              "time_cutoff": $(tr).find('td:eq(2)').val(),
              "voltage_cutoff": $(tr).find('td:eq(3)').val(),
              "current_cutoff": $(tr).find('td:eq(4)').val()
          }
      });
      TableData.shift(); // first row will be empty - so remove
      return TableData;
  }
  
  function convertArrayToJSON() {
      var TableData;
      TableData = $.toJSON(storeTblValues());
      $('#tbConvertToJSON').val('JSON array: \n\n' + TableData.replace(/},/g, "},\n"));
  
  
  }
  
  function print_r(arr, level) {
      var dumped_text = "";
      if (!level) level = 0;
  
      //The padding given at the beginning of the line.
      var level_padding = "";
      for (var j = 0; j &lt; level + 1; j++) level_padding += "    ";
  
      if (typeof (arr) == 'object') { //Array/Hashes/Objects 
          for (var item in arr) {
              var value = arr[item];
  
              if (typeof (value) == 'object') { //If it is an array,
                  dumped_text += level_padding + "'" + item + "' \n";
                  dumped_text += print_r(value, level + 1);
              } else {
                  dumped_text += level_padding + "'" + item + "' =&gt; \"" + value + "\"\n";
              }
          }
      } else { //Stings/Chars/Numbers etc.
          dumped_text = "===&gt;" + arr + "&lt;===(" + typeof (arr) + ")";
      }
      return dumped_text;
  }
  </code></pre>
  
  <p>This is probably super easy but for whatever reason I can't work out how to make it give me the values.
  Any help would be awesome.</p>