SAI YEWALE

Generation

typingsSat, 26 Nov 2022

Write javascript code to accept values from user and display the result on button click

<html> <head> <title>Html and Javascript</title> <script type="text/javascript"> function cal() { var x = document.getElementById( "t1" ).value; var y = document.getElementById( "t2" ).value; var r = parseInt(x) + parseInt(y); document.getElementById( "res" ).innerHTML = r; } </script> </head> <body> <p>Enter first number: <input type="text" id="t1"/></p> <p>Enter second number: <input type="text" id="t2"/></p> <input type="button" value="Add" onclick="cal()"/> <p>Result <span id="res"></span></p> </body> </html>

Questions about programming?Chat with your personal AI assistant