Created
August 2, 2017 01:09
-
-
Save anonymous/d67186a976a2c8268806f64ccaf86026 to your computer and use it in GitHub Desktop.
COMP484 // source http://jsbin.com/kofuduqike
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> | |
<title>COMP484</title> | |
</head> | |
<body> | |
<form action="" method="post" id="theForm"> | |
<fieldset> | |
<p>Use this form to calculate the sum.</p> | |
<div><label for="input1">Input Number</label> | |
<input type="number" id="input1" step="any" required=""></div> | |
<div><input type="submit" value="Calculate" id="submit"></div> | |
</fieldset> | |
</form> | |
<script id="jsbin-javascript"> | |
function calculate() | |
{ | |
'use strict'; | |
var num = parseInt(document.getElementById('input1').value); | |
console.log(num); | |
// var i; | |
for (var i = num; i > 1; i--) { | |
// console.log(num-1); | |
num *= i-1; | |
} | |
console.log(num); | |
return false; | |
} | |
function init() { | |
'use strict'; | |
document.getElementById('theForm').onsubmit = calculate; | |
} // End of init() function. | |
window.onload = init; | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
function calculate() | |
{ | |
'use strict'; | |
var num = parseInt(document.getElementById('input1').value); | |
console.log(num); | |
// var i; | |
for (var i = num; i > 1; i--) { | |
// console.log(num-1); | |
num *= i-1; | |
} | |
console.log(num); | |
return false; | |
} | |
function init() { | |
'use strict'; | |
document.getElementById('theForm').onsubmit = calculate; | |
} // End of init() function. | |
window.onload = init; | |
</script></body> | |
</html> |
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
function calculate() | |
{ | |
'use strict'; | |
var num = parseInt(document.getElementById('input1').value); | |
console.log(num); | |
// var i; | |
for (var i = num; i > 1; i--) { | |
// console.log(num-1); | |
num *= i-1; | |
} | |
console.log(num); | |
return false; | |
} | |
function init() { | |
'use strict'; | |
document.getElementById('theForm').onsubmit = calculate; | |
} // End of init() function. | |
window.onload = init; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment