I have a function that takes in two parameters and returns the sum.
Now I'm trying ti create an form that takes in two numbers. When button is clicked it should call the function sum and display the sum of these two numbers. What is the best way to display the return value?
My code so far:
<form>
<input type=number id=firstnumber/>
<input type=number id=secondnumber/>
<input type=button onclick=summa(document.getElementById(firstnumber),document.getElementById(secondnumber)) id=Summa value=Calculate sum/>
</form>
<div>
<script type=text/javascript>
document.write(document.getElementById(Summa))
</script>
</div>
The function:
<script type=text/javascript>
function summa(number1, number2)
{
var sum = number1 + number2;
return sum;
}
</script>