473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

HTML/Javascript Tip Calculator Not Working

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML> 
  2. <html> 
  3. <head> 
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
  5. <title>Simple Tip Calculator</title> 
  6. </head> 
  7. <body> 
  8. <form id="tip_calc"> 
  9. <p>Tip Percent: <input id="percent" /></p> 
  10. <p>Amount: <input id="amount" /></p> 
  11. <p><input type="submit" /></p> 
  12. <hr /> 
  13. <p>Tip: <input id="tip" disabled="disabled" /></p> 
  14.  
  15. <p>Total: <input id="total" disabled="disabled" /></p> </form> 
  16. </body> 
  17. <script type="text/javascript">
  18.     function calc () {
  19.  
  20.         var percent = $('#percent').val();
  21.         var amount = $('#amount').val();
  22.         var tip = (percent / 100) * amount;
  23.         var total = Number(amount) + tip;
  24.  
  25.         $('#tip').val( tip.toFixed(2) );
  26.         $('#total').val( total.toFixed(2) );
  27.  
  28.         return false; 
  29.  
  30.     $('#tip_calc').submit(calc);}
  31. </script> 
  32. </html>





Your Help Is Greatly Appreciated
Jan 30 '14 #1
2 2031
OK I didn't know, sorry about that.
Jan 30 '14 #2
Do you know what wrong with my code though? Thanks a bunch.
Jan 30 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what...
4
by: devanoy | last post by:
I have a piece of c# code in the Page_Load function. submitButton.Attributes.Add("onClick", "return checkForm('" + this + "','" + SomeTextBox.Text + "')"); When I click the submitButton, it...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
9
by: outstretchedarm | last post by:
How exactly does HTML/Javascript handle playing midi files? Does it have a player imbedded in it? Or does it borrow from the computer's midi player? How could you make a webpage play certain...
5
by: fjanon | last post by:
Is there a way to remove the default footer/header from the printed page when printing a page from HTML/Javascript in IE 6? I want to use letterhead paper and I have to remove manually the...
12
by: John | last post by:
I have to write a spyder for a webpage that uses html + javascript. I had it written using mechanize but the authors of the webpage now use a lot of javascript. Mechanize can no longer do the job....
6
by: redridinghood | last post by:
Cant understand why my javascript is working in ie6 but not in mozilla. The javascript that i hav written for validationg my form is below - <script language="JavaScript"...
9
by: ajos | last post by:
hi all, im getting some problems in my javascript validations..... my jsp code--> 8: <head> 9: <title>Budget Master Administration</title> 10: <meta name="GENERATOR" content="Microsoft...
2
by: sateeshchandrasanga | last post by:
Hi All, My HTML code is working fine in Firefox.But its not displaying any thing in IE.Can you help me in this problem.And in Google crown its displaying but not properly. ...
0
by: Fraser | last post by:
Hi; Im trying to get a calculator working in a form. <script type="text/javascript"> function startCalc<? echo $num; ?>(){ interval = setInterval("calc<? echo $num; ?>()",1); } function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.