0
How do I go about this? I want to use a HTML form to obtain two inputs (both integers) from the user. and then use JavaScript to alert the sum (or print it on the page) when the user clicks an 'Ok' button.. A simple sample code will be appreciated. thank you.
Forms and JavaScript
4 Respuestas
+ 5
HTML :
<input type=number>
<input type=number>
<button onclick="sum()">Button</button>
JS :
function sum() {
alert(document.getElementsByTagName("input")[0].value * 1 + document.getElementsByTagName("input")[1].value * 1)
}
0
thanks
0
интересно
0
what if I want to use innerHTML property to print d result on the page