引用一个Javascript写的抽奖的小程序
<html> <title>随机抽奖程序</title> <head><meta http-equiv=Content-Type content="text/html; charset=gb2312"> </head> <body> <script type="text/javascript"><!-- var alldata = "ASP,PHP,AJAX,ASP.NET,CSHARP,VB.NET,DELPHI,VB,VC,JS" //抽奖数据,以逗号分隔 var alldataarr = alldata.split(",") var num = alldataarr.length-1 var timer function change(){ document.getElementById("oknum").innerHTML = alldataarr[GetRnd(0,num)]; } function start(){ clearInterval(timer); timer = setInterval('change()',10); //随机数据变换速度,越小变换的越快 } function ok(){ clearInterval(timer); document.getElementById("showresult").value=document.getElementById("oknum").innerText; } function GetRnd(min,max){ return parseInt(Math.random()*(max-min+1)); } // --></script> <div id="oknum" name="oknum" >请单击开始抽奖</div> <button onClick="start()" accesskey="s">开始抽奖(<U>S</U>)</button> <button onClick="ok()" accesskey="o">停止(<U>O</U>)</button> <input type="text" id="showresult" value=""> </body> </html> 文章来自: 好喜爱学习网(http://www.haoxiai.net) 网址:http://www.haoxiai.net/wangzhanzhizuo/JavaScript/132495.html
女朋友说想做一个抽学号叫学生回答问题的东东,借监一下,哈哈