HTML/Javascript Tip Calculator Not Working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rez2142277
    New Member
    • Jan 2014
    • 3

    HTML/Javascript Tip Calculator Not Working

    Code:
    <!DOCTYPE HTML> 
    <html> 
    <head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    <title>Simple Tip Calculator</title> 
    </head> 
    <body> 
    <form id="tip_calc"> 
    <p>Tip Percent: <input id="percent" /></p> 
    <p>Amount: <input id="amount" /></p> 
    <p><input type="submit" /></p> 
    <hr /> 
    <p>Tip: <input id="tip" disabled="disabled" /></p> 
    
    <p>Total: <input id="total" disabled="disabled" /></p> </form> 
    </body> 
    <script type="text/javascript">
        function calc () {
    	
    	    var percent = $('#percent').val();
    	    var amount = $('#amount').val();
    	    var tip = (percent / 100) * amount;
    	    var total = Number(amount) + tip;
    	
    	    $('#tip').val( tip.toFixed(2) );
    	    $('#total').val( total.toFixed(2) );
    	
            return false; 
    	   
        $('#tip_calc').submit(calc);}
    </script> 
    </html>





    Your Help Is Greatly Appreciated
    Last edited by Rabbit; Jan 30 '14, 04:17 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • rez2142277
    New Member
    • Jan 2014
    • 3

    #2
    OK I didn't know, sorry about that.

    Comment

    • rez2142277
      New Member
      • Jan 2014
      • 3

      #3
      Do you know what wrong with my code though? Thanks a bunch.

      Comment

      Working...