title: Creating a Comparison Table from a JQuery JSON Array
body: <p>I have jQuery code with an object and a HTML checkbox selection. It's currently giving me separate tables for each selected input but since the keys (row headings) are the same for all, I actually require each selection to appear to the right of the previous selection in a single table. </p>
  
  <p>As such I need to build a simple comparison table to compare each option across parameters. How do I do this?</p>
  
  <p>Image of desired result:</p>
  
  <p><a href="https://i.stack.imgur.com/UTMqE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UTMqE.jpg" alt="enter image description here"></a></p>
  
  <p>Awaiting your inputs as I've been  struggling with this code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>jQuery(document).ready(function($) {
    var StatJSON = {
      "Opt1": {
        "Name": "Mat",
        "Parameter1": "65",
        "Parameter2": "30"
      },
      "Opt2": {
        "Name": "Mik",
        "Parameter1": "62",
        "Parameter2": "40"
      },
      "Opt3": {
        "Name": "Mir",
        "Parameter1": "65",
        "Parameter2": "90"
      }
    };
  
    $('#btnSubmit').click(function() {
      var resultString = '';
      $('input[type="checkbox"]:checked').each(function() {
        var this_input = $(this);
        if (this_input.is(':checked')) {
          resultString += PrintHtml(StatJSON[$(this).val()]);
        }
      });
      $('#divResult').html(resultString);
    });
  });
  
  function PrintHtml(obj) {
    var html = '&lt;div class="opt"&gt;';
    if (obj) {
      $.each(obj, function(k, v) {
        html += '&lt;div&gt;' + k + ' : ' + v + '&lt;/div&gt;';
      });
    }
    html += '&lt;/div&gt;';
    return html;
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.opt {
    margin: 10px;
    padding: 10px;
    background: #eee;
    border: 1px solid #222;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt;
  Options:
  &lt;input type="checkbox" name="Station" value="Opt1"&gt;Option1
  &lt;input type="checkbox" name="Station" value="Opt2"&gt;Option2
  &lt;input type="checkbox" name="Station" value="Opt3"&gt;Option3
  &lt;input id="btnSubmit" type="submit" value="submit" /&gt;
  &lt;br /&gt;&lt;br /&gt;
  &lt;div id="divResult"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>