Skip to content

Instantly share code, notes, and snippets.

@lotosotol
Last active August 29, 2015 14:14
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 lotosotol/cb8e31bbc7334c48ad26 to your computer and use it in GitHub Desktop.
Save lotosotol/cb8e31bbc7334c48ad26 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Lecture 79 - Test</title>
</head>
<body>
<p>Input your numbers below:<br /><br />
&nbsp;
<input type="text" id="myNumber1" style="width:25px; align-content:center;" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="myNumber2" style="width:25px; align-content:center;" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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&#039;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