网页抽签器

制作了一个班级抽签用的网页抽签器

random.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
<!doctype html>
<HTML>

<HEAD>
<meta charset="utf-8">
<style type="text/css">
body {
font-size: 100px;
text-align: center;
}

input {
width: 350px;
height: 140px;
font-size: 80px;
}
</style>
<TITLE>计科1702抽签 </TITLE>
<SCRIPT LANGUAGE="JavaScript">
var names = [
<!--此处写名字-->
];

var name;
var index = -1;
var time;

function begin() {
document.getElementById("btnBegin").disabled = true;
chouqian();
}

function chouqian() {
if (names.length > 0) {
index = Math.floor(Math.random() * 1000 % names.length);
name = names[index];
document.getElementById("result").innerHTML = name;

time = window.setTimeout(chouqian, 2);
} else {
document.getElementById("result").innerHTML = "~结束~";
}
}

function end() {
window.clearTimeout(time);
document.getElementById("btnBegin").disabled = false;
names.splice(index, 1);
}
</SCRIPT>
</HEAD>

<BODY>
<div>
<h3>计科1702抽签</h3>
<h1 id="result" style="color:blue;">^_^</h1>
<INPUT TYPE="button" VALUE="开始" id="btnBegin" ONCLICK="begin();">
<INPUT TYPE="button" VALUE="结束" id="btnEnd" ONCLICK="end();">
</div>
</BODY>

</HTML>