-
Notifications
You must be signed in to change notification settings - Fork 0
/
quiz.html
89 lines (78 loc) · 2.99 KB
/
quiz.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/quiz.css">
<title>Robin Jayaswal</title>
<script>
function getAnswer() {
// the following two lines of code were significantly based on code at:
// http://www.w3schools.com/js/tryit.asp?filename=try_dom_select_option
// the code is for getting the selected index of a select bar
var selectBar = document.getElementById("robinScoreSelect")
var selectedNumber = selectBar.selectedIndex + 1
if (selectedNumber < 4){
alert(selectedNumber + "? So low? A little harsh.")
}
else if (selectedNumber < 7){
alert("Yeah, " + selectedNumber + " sounds about right. Pretty mediocre")
}
else {
var aOrAn = selectedNumber === 8 ? "An " : "A "
alert(aOrAn + selectedNumber + "? Kinda high if you ask me.")
}
// the syntax for changing style of element is used from
// http://www.w3schools.com/jsref/dom_obj_style.asp
var nextButton = document.getElementById("nextButtonContainer")
nextButton.style.display = "block"
}
// function to display contents of screen after continue has been pressed
function nextScreen() {
// hide the initial elements
var initialDisplay = document.getElementById("initialDisplay")
initialDisplay.style.display = "none"
var nextButton = document.getElementById("nextButtonContainer")
nextButton.style.display = "none"
// show the previously hidden elements
var siteDisplay = document.getElementById("siteDisplay")
siteDisplay.style.display = "block"
document.body.style.height = "1250px"
}
</script>
</script>
</head>
<body>
<div class="header-box">
<span>Robin's Site</span>
</div>
<div id="initialDisplay">
<h3>Stop. Only Those Who Pass the Following Test May Enter This Site.</h3>
<span>On a scale from 1 to 10, please estimate the thing:</span>
<br>
<div class="selection-box">
<select id="robinScoreSelect">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
<br>
<input type="button" onclick="getAnswer()" value="Submit">
</div>
</div>
<div class="next-button" id="nextButtonContainer" style="display: none;">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSYCzVUKvWhwROQvo_C4crTl5V_tpCvbPV14AZV7mQAnDDruvFyApAe6rH7">
<input type="button" onclick="nextScreen()" value="Continue">
</div>
<div class="site-view" id="siteDisplay" style="display: none;">
<span></span>
<img src="http://animal-dream.com/data_images/robin/robin1.jpg">
<span>A Robin</span>
</div>
</body>
</html>