title: Creating A Javascript MultiDimentional Array From input data values
body: <p>I am working with some number of Number fields on a table.The table contains Item Name, Unit Price and Number Filed which is Quantity.Each Time Amount is increased or decreased i want an array of products/items which will contain <code>item name</code>, <code>item unit price</code>, <code>item Amount</code> , <code>total price of that item</code>.</p>
  
  <h2>For example like this</h2>
  
  <pre><code>items = 
   [
      ['Name', '5', '2', '10'],
      ['Name2', '15', '2', '30'],
   ]
  </code></pre>
  
  <p>If amount is <code>zero</code> Then that item will not take place in the array.</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() {
    jQuery(document).on('input', '.se-ticket-qty', function() {
      var items = GetItems();
  
      // jQuery('input#items').val(items);
      console.log(items);
    });
  
    function GetItems() {
      jQuery(".se-ticket-qty").each(function(index) {
        var items = [];
        var item_name = jQuery(this).data('name');
        var unit_price = parseFloat(jQuery(this).data('unit-price'));
        var amount = parseFloat(jQuery(this).val());
        var totalPrice = unit_price * amount;
  
        items = [item_name, unit_price, amount, totalPrice];
      });
      return items;
    }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Front Row&lt;/th&gt;
      &lt;td&gt;&lt;span class="se-curency"&gt;$ &lt;/span&gt;5&lt;/td&gt;
      &lt;td&gt;
        &lt;input min="0" data-name="Front Row" data-unit-price="5" class="se-ticket-qty" type="number" value="0" /&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;VIP Seat&lt;/th&gt;
      &lt;td&gt;&lt;span class="se-curency"&gt;$ &lt;/span&gt;10&lt;/td&gt;
      &lt;td&gt;
        &lt;input min="0" data-name="VIP Seat" data-unit-price="10" class="se-ticket-qty" type="number" value="0" /&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>