JS写的抽人做游戏的程序

今天打开126网盘,先升级到512M,呵呵。整理了下网盘里的资料。翻出了研究生开学时写的小程序,用来在联欢会上抽人做游戏

而且,抽出的每一组都是男女搭配,哈哈。本人不是专搞编程的,只是个人业余爱好,见笑了。

抽奖程序截图

代码直接保存成html就可以运行了,没用到任何图片。

 

代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html>
<head>
<title>style</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<script language="javascript">
// global variables
var timer;
var f1 = new Array();
var f2 = new Array();
var f3 = new Array();
var f4 = new Array();
var f5= new Array();
var f6 = new Array();
var clickTimes = 0;
var randnum1;
var randnum2;
var randnum3;
var randnum4;
var randnum5;
var randnum6;
var textnum=1;


// set data below
//
men1
f1[0]=1
f1[
1]=3
f1[
2]=5
f1[
3]=7
f1[
4]=9
f1[
5]=11
f1[
6]=13
f1[
7]=15
f1[
8]=17
f1[
9]=19
f1[
10]=21
f1[
11]=23
f1[
12]=25
f1[
13]=27
f1[
14]=29
f1[
15]=31
f1[
16]=33
f1[
17]=35
f1[
18]=77
f1[
19]=79
f1[
20]=88

//women1
f2[0]=51
f2[
1]=72
f2[
2]=37
f2[
3]=73
f2[
4]=83
f2[
5]=45
f2[
6]=41
f2[
7]=84
f2[
8]=59
f2[
9]=85
f2[
10]=86
f2[
11]=49
f2[
12]=75
f2[
13]=67
f2[
14]=87
f2[
15]=57
f2[
16]=47
f2[
17]=61
f2[
18]=81
f2[
19]=65
f2[
20]=39
f2[
21]=53
f2[
22]=69
f2[
23]=43
f2[
24]=55
f2[
25]=63
f2[
26]=71

//men2
f3[0]=2
f3[
1]=4
f3[
2]=6
f3[
3]=8
f3[
4]=10
f3[
5]=12
f3[
6]=14
f3[
7]=16
f3[
8]=18
f3[
9]=20
f3[
10]=22
f3[
11]=24
f3[
12]=26
f3[
13]=28
f3[
14]=30
f3[
15]=32
f3[
16]=34
f3[
17]=76
f3[
18]=151
f3[
19]=152
f3[
20]=153
f3[
21]=154
f3[
22]=155
f3[
23]=156

//women2
f4[0]=36
f4[
1]=38
f4[
2]=40
f4[
3]=42
f4[
4]=44
f4[
5]=46
f4[
6]=48
f4[
7]=50
f4[
8]=52
f4[
9]=54
f4[
10]=56
f4[
11]=58
f4[
12]=60
f4[
13]=62
f4[
14]=64
f4[
15]=66
f4[
16]=68
f4[
17]=70
f4[
18]=72
f4[
19]=74
f4[
20]=80
f4[
21]=82
f4[
22]=157

//men3

f5[
0]=89
f5[
1]=90
f5[
2]=91
f5[
3]=92
f5[
4]=93
f5[
5]=94
f5[
6]=95
f5[
7]=96
f5[
8]=97
f5[
9]=98
f5[
10]=99
f5[
11]=100
f5[
12]=101
f5[
13]=102
f5[
14]=104
f5[
15]=105
f5[
16]=106
f5[
17]=107
f5[
18]=108
f5[
19]=109
f5[
20]=143
f5[
21]=144
f5[
22]=145


//women3
f6[0]=110
f6[
1]=111
f6[
2]=112
f6[
3]=113
f6[
4]=114
f6[
5]=115
f6[
6]=116
f6[
7]=117
f6[
8]=118
f6[
9]=119
f6[
10]=120
f6[
11]=121
f6[
12]=122
f6[
13]=123
f6[
14]=124
f6[
15]=125
f6[
16]=126
f6[
17]=127
f6[
18]=128
f6[
19]=129
f6[
20]=130
f6[
21]=131
f6[
22]=132
f6[
23]=133
f6[
24]=134
f6[
25]=135
f6[
26]=136
f6[
27]=137
f6[
28]=138
f6[
29]=139
f6[
30]=140
f6[
31]=141
f6[
32]=142
f6[
33]=146
f6[
34]=147
f6[
35]=148
f6[
36]=149
f6[
37]=150


Total:
38

// define function

var num1 = f1.length-1;
var num2 = f2.length-1;
var num3 = f3.length-1;
var num4 = f4.length-1;
var num5 = f5.length-1;
var num6 = f6.length-1;

function checktextnum()
{
if(textnum>20)
{
document.getElementById(
"start").disabled =true;
document.all.again.style.display
="";
}
}

function getRandNum()
{
document.getElementById(
"result1").value = f1[GetRnd1(0,num1)];
document.getElementById(
"result2").value = f2[GetRnd2(0,num2)];
document.getElementById(
"result3").value = f3[GetRnd3(0,num3)];
document.getElementById(
"result4").value = f4[GetRnd4(0,num4)];
document.getElementById(
"result5").value = f5[GetRnd5(0,num5)];
document.getElementById(
"result6").value = f6[GetRnd6(0,num6)];
}

function setTimer()
{
timer
= setInterval("getRandNum();",10);
document.getElementById(
"start").disabled = true;
document.getElementById(
"end").disabled = false;
}


function GetRnd1(min,max){
randnum1
= parseInt(Math.random()*(max-min+1));
return randnum1;
}

function GetRnd2(min,max){
randnum2
= parseInt(Math.random()*(max-min+1));
return randnum2;
}

function GetRnd3(min,max){
randnum3
= parseInt(Math.random()*(max-min+1));
return randnum3;
}

function GetRnd4(min,max){
randnum4
= parseInt(Math.random()*(max-min+1));
return randnum4;
}

function GetRnd5(min,max){
randnum5
= parseInt(Math.random()*(max-min+1));
return randnum5;
}

function GetRnd6(min,max){
randnum6
= parseInt(Math.random()*(max-min+1));
return randnum6;
}

function clearTimer(){
noDupNum1();
noDupNum2();
noDupNum3();
noDupNum4();
noDupNum5();
noDupNum6();
clearInterval(timer);
document.getElementById(
"start").disabled = false;
document.getElementById(
"end").disabled = true;
}
function noDupNum1(){
// to remove the selected mobile phone number
f1.removeEleAt(randnum1);
// to reorganize the number array!!
var o = 0;
for(p=0; p<f1.length;p++){
if(typeof f1[p]!="undefined"){
f1[o]
= f1[p];
o
++;
}
}
num1
= f1.length-1;
}

function noDupNum2(){
// to remove the selected number
f2.removeEleAt(randnum2);
// to reorganize the mobile number array!!
var o = 0;
for(p=0; p<f1.length;p++){
if(typeof f2[p]!="undefined"){
f2[o]
= f2[p];
o
++;
}
}
num2
= f2.length-1;
}

function noDupNum3(){
// to remove the selected number
f3.removeEleAt(randnum3);
// to reorganize the mobile number array!!
var o = 0;
for(p=0; p<f3.length;p++){
if(typeof f3[p]!="undefined"){
f3[o]
= f3[p];
o
++;
}
}
num3
= f3.length-1;
}

function noDupNum4(){
// to remove the selected number
f4.removeEleAt(randnum4);
// to reorganize the mobile number array!!
var o = 0;
for(p=0; p<f4.length;p++){
if(typeof f4[p]!="undefined"){
f4[o]
= f4[p];
o
++;
}
}
num4
= f4.length-1;
}

function noDupNum5(){
// to remove the selected number
f5.removeEleAt(randnum5);
// to reorganize the mobile number array!!
var o = 0;
for(p=0; p<f5.length;p++){
if(typeof f5[p]!="undefined"){
f5[o]
= f5[p];
o
++;
}
}
num5
= f5.length-1;
}

function noDupNum6(){
// to remove the selected number
f6.removeEleAt(randnum6);
// to reorganize the mobile number array!!
var o = 0;
for(p=0; p<f6.length;p++){
if(typeof f6[p]!="undefined"){
f6[o]
= f6[p];
o
++;
}
}
num6
= f6.length-1;
}

function chushi()
{
document.getElementById(
"result1").value="";
document.getElementById(
"result2").value="";
document.getElementById(
"result3").value="";
document.getElementById(
"result4").value="";
document.getElementById(
"result5").value="";
document.getElementById(
"result6").value="";
document.getElementById(
1).value="";
document.getElementById(
2).value="";
document.getElementById(
3).value="";
document.getElementById(
4).value="";
document.getElementById(
5).value="";
document.getElementById(
6).value="";
document.getElementById(
7).value="";
document.getElementById(
8).value="";
document.getElementById(
9).value="";
document.getElementById(
10).value="";
document.getElementById(
11).value="";
document.getElementById(
12).value="";

document.getElementById(
13).value="";
document.getElementById(
14).value="";
document.getElementById(
15).value="";
document.getElementById(
16).value="";
document.getElementById(
17).value="";
document.getElementById(
18).value="";
document.getElementById(
19).value="";
document.getElementById(
20).value="";
textnum
=1;
document.getElementById(
"start").disabled = false;
document.getElementById(
"end").disabled = true;
}

// method to remove the element in the array
Array.prototype.removeEleAt = function(dx)
{
if(isNaN(dx)||dx>this.length){return false;}
this.splice(dx,1);
}
function setValues(){
document.getElementById(textnum).value
=""+textnum+"组: "+document.getElementById("result1").value+" "+document.getElementById("result2").value+" "+document.getElementById("result3").value+" "+document.getElementById("result4").value+" "+document.getElementById("result5").value+" "+document.getElementById("result6").value;
textnum
++;

}
function chushiload()
{
document.all.again.style.display
="none";
document.getElementById(
"result1").value="";
document.getElementById(
"result2").value="";
document.getElementById(
"result3").value="";
document.getElementById(
"result4").value="";
document.getElementById(
"result5").value="";
document.getElementById(
"result6").value="";
document.getElementById(
1).value="";
document.getElementById(
2).value="";
document.getElementById(
3).value="";
document.getElementById(
4).value="";
document.getElementById(
5).value="";
document.getElementById(
6).value="";

document.getElementById(
7).value="";
document.getElementById(
8).value="";
document.getElementById(
9).value="";
document.getElementById(
10).value="";
document.getElementById(
11).value="";
document.getElementById(
12).value="";

document.getElementById(
13).value="";
document.getElementById(
14).value="";
document.getElementById(
15).value="";
document.getElementById(
16).value="";
document.getElementById(
17).value="";
document.getElementById(
18).value="";
document.getElementById(
19).value="";
document.getElementById(
20).value="";
textnum
=1;
document.getElementById(
"start").disabled = false;
document.getElementById(
"end").disabled = true;
}

</script>

</head>
<body bgcolor="#FFFFFF" onLoad="chushiload();">
<h2><font size=36 style="filter: glow(color=red,strength=6);margin-left:5px; height:30px; color:white; padding:0px">New life,new dream</font> </h2><br>
<h2 style="margin-left:350px;font-size:29pt;display:block;
text-align:center;color:darkblue;
filter:blur(add=t,direction=135,strength=10);height:1"
>──暨纺织08硕新生联欢会</h2>
<hr height=1px>
<p align=center>
<input id="result1" type="text" size="30" style="height:110px;width:150px;border:2px solid #a1b700;font-size:100;color:red;background:transparent;" readonly/>
<input id="result2" type="text" size="30" style="height:110px;width:150px;border:2px solid #a1b700;font-size:100;color:red;background:transparent;" readonly/>
<input id="result3" type="text" size="30" style="height:110px;width:150px;border:2px solid #a1b700;font-size:100;color:red;background:transparent;" readonly/>
<input id="result4" type="text" size="30" style="height:110px;width:150px;border:2px solid #a1b700;font-size:100;color:red;background:transparent;" readonly/>
<input id="result5" type="text" size="30" style="height:110px;width:150px;border:2px solid #a1b700;font-size:100;color:red;background:transparent;" readonly/>
<input id="result6" type="text" size="30" style="height:110px;width:150px;border:2px solid #a1b700;font-size:100;color:red;background:transparent;" readonly/>
</p>
<p align=center>

<input id="start" type="button" value="开始" style="width:80px;height:40px;" onclick="setTimer();" />&nbsp;
<input id="end" type="button" value="停" style="
width:80px;height:40px;"
onclick="clearTimer();setValues();checktextnum();" disabled/>&nbsp;
<input id="again" type="button" value="再来一轮" style="width:80px;height:40px;"onclick="chushi();chushiload();" />


</p>
<p>
<hr>

<table align=center width="80%" >
<tr>
<td >

<input name="text1" id= "1" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "3" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "5" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "7" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "9" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "11" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "13" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "15" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "17" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "19" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

</td>
<td>

<input name="text1" id= "2" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "4" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "6" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "8" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "10" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "12" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "14" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "16" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "18" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

<input name="text1" id= "20" type="text" style="background:transparent;height:30px;width:500px;border:0px solid red;font-size:21;color:blue;font-weight:bold;" size="28" readonly/>

</td>
</tr>
</table>
</body>
</html>

 

 

 

posted on 2010-05-20 19:48  //一米阳光  阅读(992)  评论(0编辑  收藏  举报

导航