-
Notifications
You must be signed in to change notification settings - Fork 1
/
admindashboard.js
43 lines (33 loc) · 991 Bytes
/
admindashboard.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
showAdminDashboard();
function showAdminDashboard()
{
let candidates = localStorage.getItem("allcandidates");
if(candidates == null)
{
candidatesObj =[];
}
else{
candidatesObj = JSON.parse(candidates);
}
var c1totalvotes = 0;
var c2totalvotes = 0;
var c3totalvotes = 0;
var c4totalvotes= 0;
if(candidatesObj.length === 0 )
{
c1totalvotes = 0;
c2totalvotes = 0;
c3totalvotes = 0;
c4totalvotes= 0;
}
else{
c1totalvotes =candidatesObj[0];
c2totalvotes =candidatesObj[1];
c3totalvotes = candidatesObj[2];
c4totalvotes = candidatesObj[3];
}
document.getElementById("c1votes").innerHTML = c1totalvotes;
document.getElementById("c2votes").innerHTML = c2totalvotes;
document.getElementById("c3votes").innerHTML = c3totalvotes;
document.getElementById("c4votes").innerHTML = c4totalvotes;
}