随机抽取,简单代码。 复制代码 代码如下: 随机抽奖程序 <BR>var alldata = "a,b,c,d,e" <BR>var alldataarr = alldata.split(","); <BR>var num = alldataarr.length-1 ; <BR>var timer <BR>function change() <BR>{ <BR>document.getElementById("oknum").innerHTML = alldataarr[GetRnd(0,num)]; <BR>} <BR>function start(){ <BR>clearInterval(timer); <BR>timer = setInterval('change()',10); <BR>} <BR>function ok(){ <BR>clearInterval(timer); <BR>document.getElementById("showresult").value=document.getElementById("oknum").innerText; <BR>} <BR>function GetRnd(min,max){ <BR>return parseInt(Math.random()*(max-min+1)); <BR>} <BR> 璇峰