title: Row and Column Index in Javascript table
body: <p>I am a beginner at Javascript, and so this might seem like a basic question. </p>
  
  <p>I created a HTML table from a JSON file using javascript. The table, called "JsonTable", has 7 columns. I need to create a scatter plot, plotting column 4 and column 6. How do I select these columns? I can't find anything which will let me index the columns to select them.</p>
  
  <p>Thanks!</p>
  
  <p>Here is my code: when I run it, a table with 7 columns appears. I need to plot column 4 and column 6..</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt; &lt;/script&gt;
  
  
  &lt;/head&gt;
  &lt;body&gt;
  
  
  
  &lt;div style="margin: 20px auto; width: 500px;"&gt;
  &lt;table  border="1" cellpadding="5" id="jsonTable" style="border-collapse: collapse;"&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function addAllColumnHeaders(myList) {
      var columnSet = [];
     var headerTr$ = $('&lt;tr/&gt;');
  
      for (var i = 0; i &lt; myList.length; i++) {
          var rowHash = myList[i];
          for (var key in rowHash) {
              if ($.inArray(key, columnSet) == -1) {
                  columnSet.push(key);
                  headerTr$.append($('&lt;th/&gt;').html(key));
              }
          }
      }
      $("#jsonTable").append(headerTr$);
  
  
  
      return columnSet;
  }
  
  
  
  $.getJSON("data.json", function (data) {
  
      var columns = addAllColumnHeaders(data);
  
      for (var i = 0; i &lt; data.length; i++) {
          var row$ = $('&lt;tr/&gt;');
          for (var colIndex = 0; colIndex &lt; columns.length; colIndex++) {
  
              var cellValue = data[i][columns[colIndex]];
  
              if (cellValue == null) { cellValue = ""; }
              row$.append($('&lt;td/&gt;').html(cellValue));
          }
          $("#jsonTable").append(row$);
      }
  });
  
  &lt;/script&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>