Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiply two fields
    text
    copied!<p>There is a one section of orders page where users can add new fields to add new products. They choose a product from a drop down menu and its price is written in another column. I need to add a functionality that will allow users to enter quantity amount, and total price will be updated as soon as quantity amount changes. I tried it with the following codes but I keep receiving 0 for the total price.</p> <p>My codes.</p> <pre><code>$('#AddProduct').click(function() { var i = 0; var adding = $(+(i++)+'&lt;div class="row'+(i)+'"&gt;&lt;div class="column width50"&gt;&lt;input type="text" id="PRODUCTNAME" name="PRODUCTNAME'+(i)+'" value="" class="width98" /&gt;&lt;input type="hidden" class="PRODUCTID" name="PRODUCTID" /&gt;&lt;input type="hidden" class="UNITPRICE" name="UNITPRICE'+(i)+'" /&gt;&lt;small&gt;Search Products&lt;/small&gt;&lt;/div&gt;&lt;div class="column width20"&gt;&lt;input type="text" class="UNITQUANTITY" name="UNITQUANTITY'+(i)+'" value="" class="width98" /&gt;&lt;small&gt;Quantity&lt;/small&gt;&lt;/div&gt;&lt;div class="column width30"&gt;&lt;span class="prices"&gt;Unit Price:&lt;span class="UNITPRICE"&gt;&lt;/span&gt;&lt;br /&gt;Total Price:&lt;span class="TOTALPRICE"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="#" id="RemoveProduct(".row'+(i)+'");"&gt;Remove&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;'); $('#OrderProducts').append(adding); adding.find("#PRODUCTNAME").autocomplete("orders.cs.asp?Process=ListProducts", { selectFirst: false }).result(function(event, data, formatted) { if (data) { adding.find(".UNITPRICE").html(data[1]); adding.find(".PRODUCTID").val(data[2]); adding.find(".TOTALPRICE").html(data[1] * $('.UNITQUANTITY').val()); } }); return false; }); &lt;div id="OrderProducts"&gt; &lt;a href="#" id="AddProduct"&gt;&lt;img src="icons/add.png" alt="Add" /&gt;&lt;/a&gt; &lt;/div&gt; </code></pre>
 

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