-
Notifications
You must be signed in to change notification settings - Fork 10
/
register.js
63 lines (57 loc) · 1.92 KB
/
register.js
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
const arr = document.getElementsByTagName("input");
const btn = document.getElementById("3");
const var1 = document.getElementsByTagName("select");
var question = document.getElementById("questions");
btn.addEventListener("click", (e)=>{
var count = 0
for(let i = 0; i<3;i++){
if(arr[i].value == ""){
arr[i].classList.add("invalid");
document.getElementById(`${i}`).style.display = "inline";
} else {
arr[i].classList.remove("invalid");
count += 1;
}
}
if(var1[0].value == ""){
var1[0].classList.add("invalid");
document.getElementById("select-span").style.display = "inline";
} else {
count += 1;
}
if (count != 4){
e.preventDefault();
}
});
const arr = [];
fetch("https://task-3-api.herokuapp.com/questions")
.then((res) => res.json())
.then((data) => console.log(data));
// {
// for (j = 0; j < data.length; j++) {
// var obj = {};
// obj["question"] = data[j].question;
// obj["optionA"] = data[j].optionA;
// obj["optionB"] = data[j].optionB;
// obj["optionC"] = data[j].optionC;
// obj["optionD"] = data[j].optionD;
// obj["correctOption"] = data[j].correctOption;
// arr.push(obj);
// }
// });
var score = 0;
var i = 0;
function questions() {
question.innerText = arr[i].question;
document.getElementById("A").innerText = arr[i].optionA;
document.getElementById("B").innerText = arr[i].optionB;
document.getElementById("C").innerText = arr[i].optionC;
document.getElementById("D").innerText = arr[i].optionD;
}
var1[0].addEventListener("change", (e)=>{
if(var1[0].value != ""){
var1[0].classList.remove("invalid")
document.getElementById("select-span").style.display = "none";
}
})
// const timer = document.MediaQueryList(".timer")