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
Great thanks for sharing the content, digifutura is also a best web development company in Taiwan