Javascript lottery code Effects
This article mainly introduces the effect of the js random lottery code.
Random extraction, simple code.
The Code is as follows:
<Html>
<Title> random lottery Program </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"> click Start </div>
<Button onclick = "start ()" accesskey = "s"> start </button>
<Button onclick = "OK ()" accesskey = "o"> stop </button>
Your choice is:
<Input type = "text" id = "showresult" value = "">
</Center>
</Body>
</Html>