473,408 Members | 1,876 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,408 software developers and data experts.

Help with this HTML calculator code please?

4
Hello, I am having a little trouble with this code. I am trying to have it both Add and Subtract in the form. So far it is not displaying the answer to subtraction problems. Can you please give me a hint or help me?

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <TITLE>Calculator</TITLE>
  4.  
  5. <SCRIPT LANGUAGE="JavaScript">
  6.  
  7.  
  8. function CalculateSum(Atext, Btext, form)
  9. {
  10. var A = parseFloat(Atext);
  11. var B = parseFloat(Btext);
  12. form.Answer.value = A + B;
  13. form.sub.value = A + B;
  14. }
  15.  
  16. </SCRIPT>
  17. </HEAD>
  18.  
  19. <BODY>
  20.  
  21. <P><FONT SIZE="+2">Simple Adder</FONT></P>
  22.  
  23. <FORM NAME="Calculator" METHOD="post">
  24. <P>Enter a number: <INPUT TYPE=TEXT NAME="input_A" SIZE=10></P>
  25. <P>Enter a number: <INPUT TYPE=TEXT NAME="input_B" SIZE=10></P>
  26. <P><INPUT TYPE="button" VALUE="Add Numbers" name="AddButton" onClick="CalculateSum(this.form.input_A.value, this.form.input_B.value, this.form)"></P>
  27. <P><INPUT TYPE="button" VALUE="Subtract Numbers" name="subButton" onClick="Calculatediff(this.form.input_s.value, this.form.input_B.value, this.form)"></P>
  28. <P>Answer = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P>
  29. </FORM>
  30.  
  31. </BODY>
  32. </HTML>
Oct 5 '11 #1

✓ answered by johny10151981

WHere is your Calculatediff function?

2 2459
johny10151981
1,059 1GB
WHere is your Calculatediff function?
Oct 6 '11 #2
Rabbit
12,516 Expert Mod 8TB
Also, there's no need, they can just use the add and put in negative numbers.
Oct 6 '11 #3

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

Similar topics

3
by: Fabian | last post by:
http://www.lajzar.co.uk/unit/ Is an index page. I have javascripts to open up submenus. But tehre are quiter a lot of them, all simialr. Is there a way to unify all that javascript into a single...
6
by: Vijay | last post by:
I need to generate HTML files based on the some codes. One HTML file per code. I have the link (ex:http://123.234.345.456/WebPages/GetTestData.aspx?SomeCode=25), by passing the code as parameter I...
6
by: Rafael | last post by:
Hi Everyone, I need some help with my calculator program. I need my program to do 2 arguments and a 3rd, but the 3rd with different operators. Any help would be great. Here is my code.... ...
2
by: Newbie1234 | last post by:
The code looks like this (got this from dev++ C tutorial): #include <stdio.h> main () { int num1, num2; printf("\nEnter first number "); scanf("%d",&num1);
1
by: KiMcHeE | last post by:
Hi! I'm having a real difficult time trying to figure out what is wrong with my program code. I'm trying to make a "calculator" in the C language and I only know basic stuff. Here's my code: ...
1
by: silentscreams22 | last post by:
I need this converted. <marquee behavior="scroll" direction="down" scrollamount="3" style="position:absolute; left:110px; top:150px; width:16px; height:483px; z-index:1;"><span...
3
by: bcarlsonco | last post by:
I am currently revamping a website for a small business and there is one page giving me issues. I am doing it as a favor for a friend and am not by any means the most tech savvy on coding. There is a...
1
Markus
by: Markus | last post by:
I've searched and searched for a tutorial for sending HTML in Emails and nothing was any good. Can anyone here give me some pointers? Much appreciated.
2
by: Ecot | last post by:
Hi all, I have not got any php knowledge and I have found a php code on the net and using it to send e-mail from a web html form.So far the form and the code works fine. I have the following php...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.