-
Notifications
You must be signed in to change notification settings - Fork 6
/
投票结果.html
217 lines (194 loc) · 5.66 KB
/
投票结果.html
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="投票结果.css">
<title>投票结果</title>
</head>
<body>
<div class="bg blur"></div>
<div class= "content-front text" >
<h4>投票结果</h4>
<table id="main" >
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第一组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=1 style="background-color:#317cc7; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label0">0</label>票
</td>
</tr>
<tr>
<td>
<div type="radio" name="option" />第二组</div>
</td>
</tr>
<tr >
<td>
<div id=2 style="background-color:#0066cc; height:30px; width:0; border-width:0px; border-color:blue; border-style:solid ; text-align:right;" ></div>
</td>
<td>
<label id="label1">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" />第三组</div>
</td>
</tr>
<tr >
<td>
<div id=3 style="background-color:#a14141; height:30px;width:0; border-width:0px; border-color:blue; border-style:solid ; text-align:right;" ></div>
</td>
<td>
<label id="label2">0</label>票
</td>
</tr>
<tr>
<td>
<div type="radio" name="option" />第四组</div>
</td>
</tr>
<tr >
<td>
<div id=4 style="background-color:#5cadad;height:30px;width:0; border-width:0px; border-color:blue; border-style:solid ; text-align:right;" ></div>
</td>
<td>
<label id="label3">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第五组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=5 style="background-color:#812672; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label4">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第六组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=6 style="background-color:#c04f88; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label5">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第七组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=7 style="background-color:#89c936; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label6">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第八组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=8 style="background-color:#b8932d; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label7">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第九组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=9 style="background-color:#081522; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label8">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第十组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=10 style="background-color:#106186; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label9">0</label>票
</td>
</tr>
<tr >
<td>
<div type="radio" name="option" checked="checked"/>第十一组</div>
</td>
</tr>
<tr>
<td style="width:550px">
<div id=11 style="background-color:#520827; width:0; height:30px; border-width:0px;">
</div>
</td>
<td>
<label id="label10">0</label>票
</td>
</tr>
</table>
</div>
</body>
<script type="text/javascript">
//在每个投票选项后面写了个div,用div的宽度来代表当前该选项的投票数。
//函数vote,当点击确认投票的时候,调用vote方法
//for循环的条件是,所有投票选项的个数。
var width;
for(var i = 1; i <= document.getElementsByName("option").length; i++){
// var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
// httpRequest.open('GET', 'http://127.0.0.1:8000/polls/'+i+'/vote/', true);//第二步:打开连接 将请求参数写在url中 ps:"./Ptest.php?name=test&nameone=testone"
// httpRequest.send();//第三步:发送请求 将请求参数写在URL中
//var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
$.ajaxSettings.async = false;
$.get("http://127.0.0.1:8000/polls/"+i+"/vote/", function(width){
// alert(width);
var width_int = parseInt(width);
var z=i-1;
document.getElementById(i).style.width = width_int*20+"px";//修改原div的宽度
$("#label"+z).text(width_int);
})
// document.getElementById(1).style.width = width+"px";//修改原div的宽度
// var width_ = document.getElementById(i).style.width; //获取到当前选项的宽度。
// width_ = parseInt(width_);//将宽度转化为int型,因为获取到的width的单位是px
// width_ = width_ + width * 3;//改变width的值,这里就是定义每次投票的进度条的增速
//document.getElementById(1).style.width = width+"px";//修改原div的宽度
}
// 50 60 70 80 90 100 110 120 130 140 150 127.0.0.1:8000/polls/get_all_people/
</script>
</html>