天天看點

JS模拟抽獎

<html>
<title>妯℃???藉?(Dicky.CnBlogs.Com)</title>
<head>
<meta name="keywords" content="Dicky,AppleBBS,Dicky.CnBlogs.Com">
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
var alldata = "???規??璁哄??,Dicky.8800.Org/BBS1,Dicky.CnBlogs.Com,AppleBBS,Dicky,澶ч?ㄧ??51windows,blueidea,csdn,google,baidu,msn,qq,cctv,microsoft,adobe"    //?藉???濮???锛?浠?涓哄????

var alldataarr = alldata.split(",")
var num = alldataarr.length-1
var timer
function change(){
    document.getElementById("oknum").value = alldataarr[GetRnd(0,num)];
}

function start(){
    clearInterval(timer);
    timer = setInterval('change()',50);    //50锛?姣?绉?锛?涓哄???㈤?撮??锛?瓒?灏????㈢??瓒?蹇?
}

function ok(){
    clearInterval(timer);
}

function GetRnd(min,max){
    return parseInt(Math.random()*(max-min+1));
}
</SCRIPT>
妯℃???藉?锛?<input type="text" id="oknum" name="oknum" value="">
<button 慰nclick="start()" accesskey="s">寮?濮?(<U>S</U>)</button> 
<button 慰nclick="ok()" accesskey="o">??姝?<U>O</U>)</button>
</body>
</html>      

繼續閱讀