Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

JavaScript tutorial Simple Addition

JavaScript tutorial Simple Addition

In this tutorial we are going to learn JavaScript simple addition through input text box, complete code is given below and code is easy to understand , still if you find any kind of difficulty then please comment, I will try to clear you …

JavaScript Simple Addition Code  / Script:


<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript Simple Addition</title>
<meta charset="utf-8"/>
<!--
JavaScript Simple Addition
Tutorial by Sanjay Sir ( Codentricks )
-->
</head>
<body>

<input type="text" id="num1" />
<input type="text" id="num2" />
<input type="submit" onclick="sum()" value="Submit" />
<br/>
<div id="result"></div>

<script>
function sum(){
var num1=parseFloat(document.getElementById("num1").value);
var num2=parseFloat(document.getElementById("num2").value);
var sum;
sum=num1+num2;
document.getElementById("result").innerHTML=sum;

}
</script>
</body>
</html>

JavaScript Simple Addition Demo




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do you have any Query / Suggestion