-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (36 loc) · 1.19 KB
/
index.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
let rated= false;
let rating= 0;
for (let i = 1; i <= 5; i++) {
document.getElementById(i.toString()).classList.add("hover");
}
function submit() {
if(rated) {
document.getElementById("submit").style.backgroundColor = "white";
document.getElementById("submit").style.color = "black";
secondSite();
setRating();
}
}
function rate(id) {
if(rated) {
for(let i = 1; i <= 5; i++) {
document.getElementById(i.toString()).active = false;
}
document.getElementById(rating.toString()).classList.remove("active");
document.getElementById(rating.toString()).classList.add("hover");
}
document.getElementById(id.toString()).active = true;
document.getElementById(id.toString()).classList.add("active");
document.getElementById(id.toString()).classList.remove("hover");
rated = true;
rating = id;
}
function setRating() {
document.getElementById("selected").innerHTML = "You selected " + rating + " out of 5";
}
function secondSite() {
let firstDiv = document.getElementById("first");
let secondDiv = document.getElementById("second");
firstDiv.remove();
secondDiv.style.display = "block";
}