-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquiz1.js
More file actions
16 lines (10 loc) · 666 Bytes
/
quiz1.js
File metadata and controls
16 lines (10 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
document.getElementById("quiz1").onsubmit = function (){
a1 = parseInt(document.querySelector('input[name = "q1"]:checked').value);
a2 = parseInt(document.querySelector('input[name = "q2"]:checked').value);
a3 = parseInt(document.querySelector('input[name = "q3"]:checked').value);
a4 = parseInt(document.querySelector('input[name = "q4"]:checked').value);
a5 = parseInt(document.querySelector('input[name = "q5"]:checked').value);
result = a1 + a2 + a3 + a4 + a5;
document.getElementById("score").innerHTML = "You scored : " + result + "/100";
return false; // required to not refresh the page; just leave this here
}