
Patrick B. answered 11/24/19
Math and computer tutor/teacher
This script adds the numbers input into the text boxes and
displays the sum in an alert message box.
NEVER display output in a text box as it can be CHANGED.
Use either a label or an alert message box
I see you are using double quotes instead of single quotes.
I also see you are using the same names for the NAME and ID specs for the
input boxes
For the most part, this script does what you want it do..
====================================================
<html>
<body>
<script>
function Calculate()
{
//alert('calculate');
var num1 = document.getElementById('num1').value;
var num2 = document.getElementById('num2').value;
var sum = Number(num1) + Number(num2);
alert(' the sum is '+ sum);
}
</script>
Input First # <input type="text" id="num1" /> </br>
Input 2nd # <input type="text" id="num2"/> </br>
<button type="button" name="cmdButCALCULATE" onclick="Calculate();"> CALCULATE </button>
</body>
</html>