Friday, 15 June 2012

html - how do I subtract single textbox values with multiple textboxes values using Javascript? -


itemprop = "text">

I have a code but the problem is that since I want to reduce the total textbox value and the advance text box value is the remaining text Box. But after the values ​​are reduced in balance text box , the function may be the discount textbox value

minus the balance text box values ​​

When I am showing the total-advance and value-less balance in the textbox, but the problem is that I can not subtract the balance text box value with Discount TextBox value?

I want to do this like this

Total-Advance = Balance-Discount?

  & lt; Script type = "text / javascript" & gt; Function getObj (objID) {return document. GetElementById (objID); } Function C () {getObj ("balance"). Value = parseFloat (getObj ("total") value) - (parslot (getObj ("advance") value)); return false; } Function D () {getObj ("balance"). Value = parseFloat (getObj ("left") value) - (parslot (getObj ("discount"). Value)); return false; } & Lt; / Script & gt; & Lt; Input type = "text" name = "total" id = "total" /> & Lt; Input type = "text" name = "advance" id = "advance" /> & Lt; Input type = "text" name = "balance" id = "left" onfocus = "return C (); return D ();" / & Gt; & Lt; Input type = "text" name = "discount" id = "rebate" />    

Try it out:

Edit : Add || 0

  & lt; Input type = "text" name = "balance" id = "balance" onfocus = "return C ();" / & Gt; Function C () {var balanceValue = parseFloat (getObj ("total"), value. 0) - (perflot (getObj ("advance") value = 0)); GetObj ("balance"). Value = parseFloat (Balance Valve || 0) - (ParFlatt (getObj ("discount"). Values ​​|| 0)); return false; }    

No comments:

Post a Comment