-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
111 lines (104 loc) · 2.73 KB
/
main.php
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
include('sessions_user.php');
include ("connect.php");
$msg = "";
?>
<html>
<head>
<title>PU Elections</title>
<style>
body {
background-image:url("2.jpeg");
text-align: center;
}
.displaybox {
margin: auto;
width: 150px;
background-color: #FaFaFa;
border: 2px solid #000000;
padding: 10px;
font: 1.5em normal verdana, helvetica, arial, sans-serif;
}
h1 {
color: white;
}
h2 {
color: white;
}
.new-btn {
border:none;
border-radius: 8px;
display:inline-block;
padding:8px 16px;
text-decoration:none;
color:black;
background-color:#ccc;
text-align:center;
cursor:pointer;
position:absolute;
right:5;
top:5;
}
</style>
<script type="text/javascript">
var ajaxRequest=new XMLHttpRequest();
function getcandidatelist()
{
if (!ajaxRequest) {
document.getElementById("showcandidate").innerHTML = "Request error!ajax object could not be created";
return;
}
ajaxRequest.onreadystatechange = ajaxResponse;
ajaxRequest.open("GET","voting.php");
ajaxRequest.send();
}
function ajaxResponse()
{
if (ajaxRequest.readyState != 4)
{ return; }
else {
if (ajaxRequest.status == 200)
{
document.getElementById("showcandidate").innerHTML =
ajaxRequest.responseText; }
else {
alert("Request failed: " + ajaxRequest.statusText);
}
}
}
function verification()
{
var voted_for=document.getElementById("myform").elements['candidate'].value;
document.getElementById("showcandidate1").innerHTML=voted_for;
ajaxRequest.open("GET","result.php?sel_candidate="+voted_for);
ajaxRequest.send();
}
var count = 0;
function changeColor()
{
count++;
var col="grey";
if(count%2==0)
col="yellow";
else
col="blue";
document.getElementById('showcandidate').style.backgroundColor=col;
}
</script>
</head>
<body>
<h1>PU Elections - Welcome <?php echo $_SESSION["username"];?></h1><a href="logout.php" class="new-btn">Logout</a>
<h2>List of contenders for the Elections of the year 2017-2018</h2>
<form method="post" action="voting.php">
<input type="button" value="Get contender list" onclick="getcandidatelist();"/>
<input type="button" value="Change color" onclick="changeColor()"/>
</form>
<div id="showcandidate" class="displaybox">
</div>
<br>
<input type="submit" value="Submit" name="Submit" onclick="verification();"/>
<br>
<br>
<div id="showcandidate1" class="displaybox"></div>
</body>
</html>