Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;section&gt; &lt;p&gt;Please enter the desired product/services in the following table to create an order.&lt;/p&gt; &lt;section style="width:300px; margin-left:20px"&gt; &lt;form action="" name="order" method="POST" autocomplete="off"&gt; &lt;table id="cart" width="300" border="0" cellspacing="5" cellpadding="2"&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="product"&gt;Product:&lt;/label&gt; &lt;/td&gt; &lt;td&gt; &lt;input name="product" required pattern="[a-zA-Z ]*$" title="Please enter only alphabetic characters" type="text" placeholder="Product name" size="28" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="quantity"&gt;Quantity:&lt;/label&gt; &lt;/td&gt; &lt;td&gt; &lt;input name="quantity" required type="number" title="Enter item quantity" placeholder="Product quantity" width="196px" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="price"&gt;Price:&lt;/label&gt; &lt;/td&gt; &lt;td&gt; &lt;input name="price" required pattern="[0-9]" title="Please enter only numeric characters" placeholder="Product price" size="28" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br&gt; &lt;div id="buttons"&gt; &lt;input type="reset" name="reset" id="resetbtn" class="resetbtn" value="Reset"&gt; &lt;input type="submit" name="submit" id="submitbtn" class="submitbtn" tabindex="7" value="Submit this!" onclick=""&gt; &lt;br style="clear:both;"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/section&gt; &lt;/section&gt; &lt;table width="416" border="0" cellspacing="5" cellpadding="2" id="cart"&gt; &lt;tr&gt; &lt;th width="115" scope="col"&gt;Products&lt;/th&gt; &lt;th width="112" scope="col"&gt;Quantity&lt;/th&gt; &lt;th width="92" scope="col"&gt;Price&lt;/th&gt; &lt;th width="56"&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td id="items"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td scope="col"&gt;&amp;nbsp;&lt;/th&gt; &lt;td scope="col"&gt; &lt;/th&gt; &lt;td scope="col"&gt;&amp;nbsp;&lt;/th&gt; &lt;th&gt;Total&lt;/th&gt; &lt;td id="total"&gt;0&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;script&gt; $(document).ready(function(){ var form = document.order; var $checkout = $('#cart'); // Listen for form submit $(form).on('submit', function(e){ // Prevent browser from sending form e.preventDefault(); // this is a row thats nt yet attached to the document var $row = $('&lt;tr class="item"&gt;'); /* * Loop through fields and add 'product','quantity','price' * to $row. we store the data on the node as well */ $.each(['product','quantity','price'],function(index, key){ var $td = $('&lt;td&gt;'); var value = form[key].value; $td.addClass(key).text(value); $row.data(key, value); $row.append($td); }); // Attach the $row to the document $('#items').append($row); // Update the totals $checkout.trigger('change'); }); // Update totals when cart changes $checkout.on('change',function(){ var total = 0; $(this).find('.item').each(function(){ var quant = parseFloat($(this).data('quantity')); var price = parseFloat($(this).data('price')); total = total + (quant * price); }); $('#total').text(total); }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload