Javascript examples for DOM HTML Element:Input Number
adding two numbers from input box values
<html> <head> <script> function addFunction() {// ww w. j av a 2 s . c o m var x = parseInt(document.getElementById("firstInput").value); var y = parseInt(document.getElementById("secondInput").value); var sum=x+y; console.log('Sum is:'+sum); } </script> </head> <body> <input type="text" id="firstInput"> <br> <input type="text" id="secondInput" onchange="myFunction()"> <br> <input type="button" value="Add" onclick="addFunction()"> </body> </html>