Asp模拟抽奖

本文介绍了一个使用ASP编写的简单抽奖程序。该程序通过JavaScript实现了一个抽奖功能,包括开始和停止按钮,能够从预设的数据集中随机抽取获奖者,并显示其工号和姓名。此外,程序还具备将已抽取的获奖者标记为不可重复抽取的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 <!--#include file = "Inc/DBClass.inc.asp"-->
  <HTML><HEAD>
  <META http-equiv=Content-Type content="text/html; charset=gb2312">
  <SCRIPT language=javascript>
  <!--
 
  var onecount;
  onecount=0;
  subcat = new Array();

<%

strSql = "Select top 3 Id,RealName From Reguser ORDER BY NEWID()"
    Set Rs = Server.CreateObject("adodb.recordset")
    Rs.Open strSql,oconn,1,3

for i=0 to rs.recordcount
if rs.eof or rs.bof then exit for
response.write ("subcat["&i&"] = new Array('"&i&"','"&rs("id")&"','"&rs("RealName")&"');")&VBNEWLINE
//vbNewLine相当于 CHR(13)+CHR(10)

rs.movenext
next
response.write ("onecount="&i-1&";")


%>
/*
subcat[0] = new Array('0','173','江霖');
subcat[1] = new Array('1','84','吴宁');
subcat[2] = new Array('2','159','孔涛');
onecount=2;
*/
  function cs(locationid)
    {
    var locationid=locationid;
          if (subcat[locationid][0] == locationid)
          {  
document.getElementById("user").innerText=document.getElementById("user").innerText+'  '+subcat[locationid][2]
alert("恭喜,获奖信息已经产生!/n/n"+"员工工号:"+subcat[locationid][1]+"/n/n员工姓名:"+subcat[locationid][2]);
          }      
    }    
 
  //-->

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

  myarray=new Array();
  function thepush(data){myarray.push(data);}
  function tt()
  {
  var tmp1;
  tmp1=GetRnd(0,onecount);
  if(subcat[tmp1][0] != -1)
  {
  form.id.value=subcat[tmp1][1];
  form.hid.value=subcat[tmp1][0];  
  }  
  }    
  var startPressed=false;
  var bgChangeStarted=false;
  function startit()
  {
  if(!startPressed)
  {
  document.getElementById("b1").disabled=true;
  document.getElementById("b2").disabled=false;
  startPressed=true;  
  timerID=setInterval("tt()",10);  //10(毫秒)为变换间隔,越小变换的越快
  bgChangeStarted=true;  
  }
  }
  function stopTest()
  {
if(bgChangeStarted){  
  document.getElementById("b1").disabled=false;
  document.getElementById("b2").disabled=true;
  cs(form.hid.value);
  /*
  这里很重要 将选中的记录置位-1  tt()=>if(subcat[tmp1][0] != -1)
  将排除已经选择的记录
  如果不置位 new Array("-1","","",""); 选择过的纪录可以再次选择。
  */
  subcat[form.hid.value] = new Array("-1","","","");
  /////////////////////
  clearTimeout(timerID);
  startPressed=false;
  bgChangeStarted=false;
  thepush(form.hid.value);
  }
}
</SCRIPT>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
font-size: 15px;
color: #FF0000;
font-weight: bold;
}
.show {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 55px;
color: #FF0000;
background-color: #D4D0C8;
border: 0px solid #999999;
background-position: center;
text-align: center;
}
-->
</style>
  <body bgcolor="#D4D0C8">
<FORM name=form><div align=center><br/><br/>
<fieldset style="height:188px;width:80%;">
<legend>
<button id=b1 onclick=javascript:startit(); accesskey="s" > 开始(<U>S</U>) </button>
<button id=b2 onclick=javascript:stopTest(); accesskey="o" disabled="true"> 停止(<U>O</U>) </button>
<button id=b3 onclick=javascript:location.reload(); accesskey="R"> 刷新(<U>R</U>) </button>
</legend>
<div align=center><br/><br/><INPUT align=center size=20 value="Please press start!" name=id class=show></div>
<INPUT type="hidden" name="hid">
</fieldset>
<fieldset style="height:188px;width:80%;"><legend>获奖人员名单</legend>
<br/><br/><div align=center id="user"></div>
<!--<INPUT id=b1 onclick="document.getElementById('user').innerText='';" type=button value=" 清空 " name=b1> -->
</fieldset>
</div></FORM>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值