Tuesday 15 September 2015

Javascript continuous function -


I want to write a function that constantly underlines the data from a form. I am creating a form that is priced and sold and it produces total value. On the edit info, I want my function to automatically update the total value without clicking on a button. For example, if the value of $ 10 with 5% tax would be $ 10.50. If I change the price to $ 5 then I want to update the full price automatically. I am looking for some guidance to do this.

You have written it to me

I have written this basic example:

< P> HTML:

  & lt; Form & gt; Price: & lt; Input type = "text" id = "price" onchange = "calculate ()" /> Taxes: & lt; Input type = "text" id = "tax" onchange = "calculate ()" /> & Lt; / Form & gt; Total: & lt; Span id = "total" /> Javascript:  
  function count () {var price = parseInt (document.getElementById ("price"). Value, 10); Var tax = parseInt (document.getElementById ("tax"). Value, 10); If (IsNaN (value) & IsNa (tax)) {document.getElementById ("Total"). InnerHTML = (100 + tax) * value / 100; }}  

No comments:

Post a Comment