<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> 抽奖活动 </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="Content-Language" content="zh-CN"/>
<title>抽奖活动</title>
<style type="text/css">
body {padding-top:100px;font:12px "\5B8B\4F53",sans-serif;text-align:center;}
.result_box {margin:0 auto;width:700px;padding:100px 0;text-align:center;border:3px solid #40AA53;background:#efe;}
.result_box #oknum {width:680px;color:#cc0000;font-size:100pt;font-family:Verdana;text-align:center;border:none;background:#efe;}
.result_box2 #oknum_list{width:700px;border:1px solid #40AA53;background:red}
.button_box {margin:50px 0 0 0;}
.button_box .btn {cursor:pointer;padding:0 30px;margin:0 10px;color:#555;font-family:"\5B8B\4F53",sans-serif;font-size:40px;}
</style>
</head>
<body background="./img/1.jpg">
<script type="text/javascript">
//抽奖人数
var num = 200
var resFileName="C:/result.txt"
var timer;
var workers=new Array(num + 1)
var gLine="";
window.onload=function(){
readFile(resFileName);
}
//读文件
function readFile(filename){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(filename,1);
var s = "";
while (!f.AtEndOfStream)
{
var line = f.ReadLine();
gLine = line;
document.getElementById("oknum_list").value = gLine;
var subArray=line.split(",");
var len = subArray.length;
for(var i in subArray){
var item = subArray[i];
if(item != ""){
workers[item]=1;
}
}
}
f.Close();
return s;
}
//写文件
function writeFile(filename, filecontent){
var fso, f, s ;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(filename,8,true);
f.Write(filecontent);
f.Close();
}
function change(){
value = GetRnd(0,num) + 1;
if(workers[value] != 1)
document.getElementById("oknum").value = value;
}
function start(){
clearInterval(timer);
timer = setInterval('change()',50); //随机数据变换速度,越小变换的越快
}
function ok(){
clearInterval(timer);
//以下代码表示获得奖的,不能再获奖了。 重置刷新页面即可。
var value=document.getElementById("oknum").value;
if(workers[value] != 1) {
workers[value] = 1;
writeFile(resFileName,value+",");
gLine += value+",";
document.getElementById("oknum_list").value = gLine;
}
}
function GetRnd(min,max){
return parseInt(Math.random()*(max-min));
}
document.onkeydown = function(e){
if(e.keyCode==13)
start();
if(e.keyCode==32)
ok();
};
</script>
<div class="result_box"><input type="text" id="oknum" name="oknum" value="抽奖结果" /></div>
<div class="result_box2"><input type="text" id="oknum_list" name="oknum_list" value="中奖号码" /></div>
<div class="button_box"><button class="btn" onclick="start()" accesskey="s">开始(<U>S</U>)</button><button class="btn" onclick="ok()" accesskey="o">停止(<U>O</U>)</button></div>
</body>
</html>
</body>
</html>
抽奖程序源码
1星 需积分: 42 100 浏览量
2018-01-29
17:53:40
上传
评论 1
收藏 115KB ZIP 举报
ulan_sheng
- 粉丝: 0
- 资源: 6