I need help to create a function that:
- Contains information of the total sum of all numbers the user has input so far is calculated, printed to console, and stored on HTML page.
- When the total sum is larger than 100, the function prints "it's over" to console.
Any suggestions? Below is what I've got so far:
function adder() {
var num1 = parseInt(document.getElementById("myform").elements["num1"].value);
var num2 = parseInt(document.getElementById("myform").elements["num2"].value);
var total = num1 + num2;
document.getElementById("p1").innerHTML = total;
}
<form id="myform">
First Number: <input type="text" name="num1"><br /><br /> Second Number: <input type="text" name="num2"><br /><br />
</form>
<button onclick="adder()"> Submit</button><br><br>
<p id="p1">Results Are Here</p>