Created
September 12, 2012 01:58
-
-
Save jpetto/3703712 to your computer and use it in GitHub Desktop.
Week 2 Classwork Helper
This file contains hidden or 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></title> | |
</head> | |
<body> | |
<form id="racer_form"> | |
<input type="text" name="alphabet" id="alphabet" /> | |
<button type="button" id="start">Start Typing!</button> | |
<button type="submit" id="stop">Finished!</button> | |
</form> | |
<script type="text/javascript"> | |
// get references to my buttons and form | |
var form = document.querySelector('#racer_form'); | |
var textbox = document.querySelector('#alphabet'); | |
var start = document.querySelector('#start'); | |
var end = document.querySelector('#end'); | |
// declare date variables | |
var start_time; | |
var end_time; | |
start.onclick = function(e) { | |
// focus the text box | |
alphabet.focus(); | |
// store the time they start typing | |
start_time = new Date(); | |
console.log(start_time); | |
} | |
form.onsubmit = function(e) { | |
e.preventDefault(); | |
// store the time they finished | |
end_time = new Date(); | |
var total = end_time.getTime() - start_time.getTime(); | |
console.log(end_time); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment