直接黏贴代码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>随机抽奖程序</title>
</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>