Skip to content

Instantly share code, notes, and snippets.

@joshcooper
Created December 14, 2016 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshcooper/217e6d7376389e7c55a0f6195caa65fa to your computer and use it in GitHub Desktop.
Save joshcooper/217e6d7376389e7c55a0f6195caa65fa to your computer and use it in GitHub Desktop.
<html>
<body>
<p>Enter a number: <input id="number1" type="text"/>
<p>Enter another number: <input id="number2" type="text"/>
<p id="answer"></p>
<button onclick="myFunction()">Calculate</button>
<script>
function myFunction() {
var x = document.getElementById("number1").value;
var y = document.getElementById("number2").value;
var sum = Number(x) + Number(y);
document.getElementById("answer").innerHTML = sum;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment