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




0 0 votes
Article Rating
Subscribe
Notify of
guest

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

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Digi

Great thanks for sharing the content, digifutura is also a best web development company in Taiwan