Posted in Javascript onDecember 02, 2013
随机抽取,简单代码。
<html> <title>随机抽奖程序</title> <head><meta http-equiv=Content-Type content="text/html; charset=gb2312"> </head> <body> <script type="text/javascript"> var alldata = "a,b,c,d,e" 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> <center> <div id="oknum" name="oknum" >请单击开始</div> <button onclick="start()" accesskey="s">开始</button> <button onclick="ok()" accesskey="o">停止</button> 您的选择是: <input type="text" id="showresult" value=""> </center> </body> </html>
js抽奖实现随机抽奖代码效果
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@