-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz.html
64 lines (59 loc) · 2.27 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Quiz</title>
<style>
.questions{
margin-bottom: 20px;
}
label{
margin-bottom: 10px;
display: block;
}
</style>
</head>
<body>
<div class="quiz">
<div class="questions">
<p>1.Which is my favourite kpop boy band?</p>
<div class="options">
<label><input type="radio" name="q1" value="BTS">BTS</label>
<label><input type="radio" name="q1" value="EXO">EXO</label>
<label><input type="radio" name="q1" value="SEVENTEEN">SEVENTEEN</label>
<label><input type="radio" name="q1" value="Stray kidz">Stray kidz</label>
</div>
</div>
<div class="questions">
<p>2.Who is my bias?</p>
<div class="options">
<label><input type="radio" name="q2" value="Joshua">Joshua</label>
<label><input type="radio" name="q2" value="Mingyu">Mingyu</label>
<label><input type="radio" name="q2" value="DK">DK</label>
<label><input type="radio" name="q2" value="Hoshi">Hoshi</label>
</div>
</div>
<button id="submit-btn" onclick="calculatescore()">Submit</button>
<div id="result"></div>
</div>
<script>
function calculatescore(){
var score=0;
var q1Answer=document.querySelector('input[name="q1"]:checked');
if(q1Answer && q1Answer.value==="SEVENTEEN"){
score++;
}
var q2Answer=document.querySelector('input[name="q2"]:checked');
if(q2Answer && q2Answer.value==="Joshua"){
score++;
}
var result=document.getElementById("result");
result.innerHTMl="Your Score:"+score+"/2";
if(score===2){
result.innerHTML='Congratulations!!!';
}else{
result.innerHTML='Better luck next Time!!!'
}
}
</script>
</body>
</html>