Last active
August 29, 2015 14:14
-
-
Save lotosotol/cb8e31bbc7334c48ad26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Lecture 79 - Test</title> | |
</head> | |
<body> | |
<p>Input your numbers below:<br /><br /> | |
| |
<input type="text" id="myNumber1" style="width:25px; align-content:center;" /> | |
| |
<input type="text" id="myNumber2" style="width:25px; align-content:center;" /> | |
| |
<button type="button" id="calcButton">CalculateSUM</button></p> | |
<br />Results are: <p id="paragraph"></p> | |
<script type="text/javascript"> | |
document.getElementById("calcButton").onclick=function adding() { | |
function adding(a, b) { | |
result=(a+b); | |
console.log(result); | |
return(result); | |
} | |
a=document.getElementById("myNumber1").value; | |
b=document.getElementById("myNumber2").value; | |
console.log(a); | |
console.log(b); | |
//calling the function by giving 2 inputs so they'll be calculated and added to the paragraph | |
document.getElementById("paragraph").innerHTML=adding(a, b); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment