Asp模拟抽奖

 <!--#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 οnclick=javascript:startit(); accesskey="s" > 开始(<U>S</U>) </button>
<button id=b2 οnclick=javascript:stopTest(); accesskey="o" disabled="true"> 停止(<U>O</U>) </button>
<button id=b3 οnclick=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 οnclick="document.getElementById('user').innerText='';" type=button value=" 清空 " name=b1> -->
</fieldset>
</div></FORM>

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页