Note that there are some explanatory texts on larger screens.

plurals
  1. POOn keypress of jquery change the value of textbox
    text
    copied!<p>I got the JSON data from my ASP.net MVC Controller, and loop it to display in my View. </p> <p><img src="https://i.stack.imgur.com/FAfX8.png" alt="enter image description here"></p> <pre><code>$(document).ready(function () { var amount = 0; var subTotal = 0; var vat = 0; var total = 0; var qty = 0; var urlSession = '&lt;%: Url.Content("~/") %&gt;' + "Quotation/ProductInSession"; $.getJSON(urlSession, function (dataQuote) { var i = dataQuote.ja.length; $.each(dataQuote.ja, function (index, data) { amount = data.ProductQty * data.ProductPrice; subTotal += amount; $("#listProduct tr#first_row").after('&lt;tr style="height:25px;"&gt;&lt;td class="tablecell2" width="40px" align="center"&gt;' + i + '&lt;/td&gt;&lt;td class="tablecell2"&gt;' + data.ProductName + '&lt;/td&gt;&lt;td class="tablecell2" width="70px" align="center"&gt;&lt;input id="qty" type="text" value="' + data.ProductQty + '" size="2"/&gt;&lt;/td&gt;&lt;td class="tablecell2" width="90px" align="right" style="padding-right:5px;"&gt;' + data.ProductPrice + '&lt;/td&gt;&lt;td class="tablecell2" style="border-right:1px solid silver;padding-right:5px;" width="120px" align="right"&gt;&lt;span id="amount"&gt;' + amount + '&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;'); i--; $('#qty').keypress(function (event) { var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode == '13') { qty = $("#qty").val(); $("#qty").html(qty); amount = qty * data.ProductPrice; $("#amount").html(amount); } }); }); vat = (subTotal * 10) / 100; total = subTotal + vat; $("#vvat").html("&lt;b&gt;" + vat + "&lt;/b&gt;"); $("#ssubtotal").html(subTotal); $("#sgrandtotal").html("&lt;b&gt;" + total + "&lt;/b&gt;"); }); }); </code></pre> <p>What I want to do is :</p> <ol> <li>Change the value in textbox when I press the key Enter</li> <li>Change the value of the amount (amount = qty * UnitPrice)</li> </ol> <p>Should I create another action of the controller to handle this update or anything beside this.</p> <p>Thanks for any help anyone can give me!</p> <p>The </p>
 

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