Skip to content

Instantly share code, notes, and snippets.

@joshcooper
Last active December 14, 2016 02:49
Show Gist options
  • Select an option

  • Save joshcooper/002fd0a8238f4517a07becdb593478ea to your computer and use it in GitHub Desktop.

Select an option

Save joshcooper/002fd0a8238f4517a07becdb593478ea to your computer and use it in GitHub Desktop.
<html>
<body>
Enter a number: <input id="number1" type="text"/>
<br>
Enter another number: <input id="number2" type="text"/>
<button onclick="myFunction()">Calculate</button>
<p id="answer"></p>
<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