VB icon

Addition and Subtraction of Two Numbers in JavaScript

Email
Submitted on: 5/14/2016 12:38:47 AM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: JavaScript
Views: 8375
author picture
 
     Hi there thank you for visiting my website I have a very busy week in my work that why I was not able to update my blog anyway moving forward. In this sample program will show you how to add and subtract two numbers using HTML forms in JavaScript. The code is very easy to understand for beginners that are new in JavaScript. I hope you will find my work useful. Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Addition and Subtraction of Two Numbers in JavaScript
' Description:Hi there thank you for visiting my website I have a very busy week in my work that why I was not able to update my blog anyway moving forward. In this sample program will show you how to add and subtract two numbers using HTML forms in JavaScript. The code is very easy to understand for beginners that are new in JavaScript. I hope you will find my work useful.
 Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com
My mobile number here in the Philippines is 09173084360.
' By: Jake R. Pomperada
'**************************************

<!DOCTYPE html> 
<html>
<head> 
<meta charset=utf-8 /> 
<title>Addition and Subtraction of Two Numbers in JavaScript</title> 
<style type="text/css"> 
body {
font-family:arial;
	font-size:12;
	font-weight:bold;
background-color:lightgreen;
	margin: 30px;
	}
</style>
</head> 
<body> 
<script>
function AdditionBy() 
{ 
num1 = document.getElementById("first").value; 
num2 = document.getElementById("second").value; 
document.getElementById("result").innerHTML = Number(num1) + Number(num2); 
} 
 
function SubtractionBy()
{
num1 = document.getElementById("first").value; 
num2 = document.getElementById("second").value; 
document.getElementById("result").innerHTML = Number(num1) - Number(num2); 
} 
</script>
<hr>
<h2> Addition and Subtraction of Two Numbers in JavaScript </h2>
 <hr>
<form> 
Give 1st Number : <input type="text" id="first" maxlength="4"/ size="4"><br> 
Give 2nd Number : <input type="text" id="second" maxlength="4" size="4" />
<br><br>
<input type="button" onClick="AdditionBy()" Value="Addition" 
title="Click here to find the sum of the two numbers." />  
<input type="button" onClick="SubtractionBy()" 
title="Click here to find the differece of the two numbers." 
Value="Subtraction" /> 
</form> <br><br>
<p>The Final Result is : 
<span id = "result"></span> 
</p> 
</body> 
</html>


Other 108 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.