Wednesday, 15 January 2014

jquery - How do I get this simple sales tax calculator to not break and clear fields? -


All I'm trying to do is not get it when I calculate, and clear the clear button two Make text field I know that I have a simple error and it's okay okay, thanks for the help!

  & lt; Form id = "form" & gt; Sub Total: & lt; Input id = "uptot" value = "5" type = "text" /> gt; & Lt; Br / & gt; Tax%: & lt; Input id = "tax" value = "6" type = "text" /> gt; & Lt; Br / & gt; & Lt; Input id = "calc" type = "submit" value = "calculation" /> & Lt; Input id = "reset" type = "submit" value = "clear" /> & Lt; / Form & gt;   

jquery:

  $ (function () {$ ('# calc'). Click (function () {var taxf = ($ ( 'Val () / 100); Val () (= (' $ subtot '). Val () * (Taffe + 1)) Tofix (2); Alert ("Your total is $"); $ (' # Form '). Submit ();}); addTax ()})    

You need to change some stuff.

Whatever has changed:

  1. Your reset button is of this type.
  2. Setting hard-coded values ​​as default is defined by They will not be eligible to reset.
  3. The final closing cell for the semi-colon and good practice has been added to your function call.

    HTML:

      
    form ID = "form" & gt; sub total: & lt; input id = "uptot" value = "" type = "text" /
    Tax%: & lt; Input ID = "tax" value = "" type = "article" /> gt;
    & lt; input id = "Calc" type = "submit" value = "calculation" /> & Lt; Input id = "reset" type = "reset" value = "reset" /> & Lt; / Form & gt; Click the

    jquery:

      $ (function () {$ ('# calc') (function () { Var taxf = ($ ('$ tax') Val () / 100); var tot = ($ ('# subtot'). Val () * (taxf + 1)) toFixed (2); Alert ("Your Total is $ "+ tot); $ ('# form'). Submit ();}); addTax ();});    

No comments:

Post a Comment