title: Generate table, store values from json array
body: <p>I need to create tables for each index in a given array, also i need to store those values so that my for loops sends them to the tables created.</p>
  
  <p>JavaScript: 
  <code>for (c=0; c &lt; components_count.length; c++)
  {
      console.log(components_count[c]);
  }</code></p>
  
  <p>how can this be done?</p>
  
  <p>Here is the full JS: </p>
  
  <pre><code>var index;
  var data;
  var parsed;
  
      $(document).ready(function() {
       $.get('policy.json', function(data){
    index = data;
  
   },"json");
  
   });
  
  function search(){
  
  var movement_select = $("#movements").val();
  
  var id = $("#idSubmit").val();
  
  var refnr = index.refnr;
  
  var index_movements = index.movements;
  
  //console.log(movement_select);
  
  //for loop to test which movement from dropdown list! Done!
  
  for (m=0; m &lt; index_movements.length; m++)
  {
  
      if (index_movements[m].date == movement_select)
      {
          movement_select = index_movements[m];
  
      }
  
  }
  
  
  var movements = index.movements;
  var movements_description = movement_select.description;    
  var movements_premium = movement_select.premium;
  
  var movements_payer = movement_select.payer;
  var movements_payer_id = movement_select.payer.personid;
  var movements_payer_name = movement_select.payer.name;
  var movements_payer_surname = movement_select.payer.surname;
  var movements_payer_fullname = movements_payer_name + " " + movements_payer_surname;
  
  var movements_owner = movement_select.owner;
  var movements_owner_id = movement_select.owner.personid;
  var movements_owner_name = movement_select.owner.name;
  var movements_owner_surname = movement_select.owner.surname;
  var movements_owner_fullname = movements_owner_name + " " + movements_owner_surname;
  
  var components_count = movement_select.components;
  
  for (c=0; c &lt; components_count.length; c++)
  {
      console.log(components_count[c]);
  }
  
  var components = movement_select.components[0];
  var components_description = movement_select.components[0].description;
  var components_premium = movement_select.components[0].premium;
  var components_cover = movement_select.components[0].cover;
  var components_commencementdate = movement_select.components[0].commencementdate;
  
  // table 1 --------------------------------------------------
  
  $("#id").html(id);
  $("#refnr").html(refnr);
  $("#movements_payer_fullname").html(movements_payer_fullname);
  $("#movements_owner_fullname").html(movements_owner_fullname);
  $("#refnr").html(refnr);
  
  // table 2 --------------------------------------------------
  
  
  }
  </code></pre>
  
  <p>and here is the JSON:</p>
  
  <pre><code>{
  "policyid":"1000",
  "refnr":"gcsa000923",
  "movements":
  [
      {
          "date":"2012/06/01",
          "description":"Accept",
          "premium":"R30.00",
          "payer":{"personid":"928374","name":"Hansie","surname":"slim"},
          "owner":{"personid":"928374","name":"Hansie","surname":"slim"},
          "components":
          [
              {
                  "description":"Basic cover",
                  "premium":"R10.00",
                  "cover":"R0.00",
                  "commencementdate":"2012/06/01"
              },
              {
                  "description":"Cancer",
                  "premium":"R10.00",
                  "cover":"R20 000.00",
                  "commencementdate":"2012/06/01"
              }
          ]
      },
      {
          "date":"2012/08/01",
          "description":"Policy Alteration",
          "premium":"R30.00",
          "payer":{"personid":"928374","name":"Hansie","surname":"slim"},
          "owner":{"personid":"928374","name":"Hansie","surname":"slim"},
          "components":
          [
              {
                  "description":"Basic cover",
                  "premium":"R10.00",
                  "cover":"R0.00",
                  "commencementdate":"2012/06/01"
              },
              {
                  "description":"Cancer",
                  "premium":"R10.00",
                  "cover":"R20 000.00",
                  "commencementdate":"2012/06/01"
              },
              {
                  "description":"Disability cover",
                  "premium":"R20.00",
                  "cover":"R40 000.00",
                  "commencementdate":"2012/09/01"
              }
  
          ]
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>Solved: 
  <code>for (c=0; c &lt; components_count.length; c++)
      {
          $('#append').append("Description: " + components_count[c].description + " " + '&lt;br&gt;');
          $('#append').append("Premium: " + components_count[c].premium + " " + '&lt;br&gt;');
          $('#append').append("Cover: " + components_count[c].cover + " " + '&lt;br&gt;');
          $('#append').append("Commencement Date: " + components_count[c].commencementdate + " " + '&lt;br&gt;' + '&lt;br&gt;');
      }</code></p>
  
  <p>I forgot about .append ^^ </p>