how to calculate values from one text box and set it to another textbox using jquery

> **Possible Duplicate:** > [Unable to get textfield value using jQuery](https://stackoverflow.com/questions/13438570/unable-to-get-textfield-value-using-jquery) i have a invoice where i am iterating values from a list. There i have textbox named `subtotal` , this textbox holds some number. And another textbox named `discountamt` ,in this textbox user will enter discount in number,which will be calated as `discountamt percentage subtotal` .i.e(`discountamt % subtotal`) eg. 10% of subtotal. And the calculated amount should reduce from subtotal and should set in anther textbox named `overalltotal` . Please see my below image which shows how my output should be... ![enter image description here][1] Below is my code, where i am trying to implement this
Sub Total.
Discount:
Over All Total Amount:
**UPDATE Correct Answer:** $('input[name="discountamt"]').keyup(function() { var disamount=$('[name=discountamt]').val(); var linetotal = $('[name=subtotal]').val(); var priceafterdisc=linetotal-(((disamount)/100)*linetotal); $('[name=overalltotal]').val(priceafterdisc); }); Please help me to solve this issue... [1]: http://i.stack.imgur.com/OUSMW.png
Forgive the impertinence, but why are you allowing your users to set everything (i.e., because it's in an input field, what prevents them from changing the price or line total of book title Two to 0.00, or from setting a discount of 100%)? Also, since you're apparently calculating client-side, what event should trigger the calculation?

以上就是how to calculate values from one text box and set it to another textbox using jquery的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏