Lottery programs written in Javascript
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> lottery Program </title>
<Script language = "JavaScript">
VaR timer;
VaR flag = 0;
// Obtain a random number
Function getrandomnum (){
VaR F1 = Document. getelementbyid ("f1 ");
VaR F2 = Document. getelementbyid ("F2 ");
VaR fv1 = f1.value;
VaR fv2 = f2.value;
VaR result = Document. getelementbyid ("result ");
VaR Rand = 0;
If (! Flag & (fv1 = "" | fv2 = "" | fv1> = fv2 )){
Flag = 1;
Alert ("You must enter the start number and end number, and the START number cannot be greater than the end number ");
Return false;
}
Fv2 = fv2* 1.5;
Rand = parseint (math. Random () * (fv2-fv1 + 1) + fv1 );
If (RAND> f1.value & Rand <f2.value ){
Result. value = rand;
}
}
// Start
Function settimer (){
Timer = setinterval ("getrandomnum ();", 10 );
Document. getelementbyid ("START"). Disabled = true;
Document. getelementbyid ("end"). Disabled = false;
}
// Stop
Function cleartimer (){
Clearinterval (timer );
Document. getelementbyid ("START"). Disabled = false;
Document. getelementbyid ("end"). Disabled = true;
}
</SCRIPT>
</Head>
<Body>
<Center>
<Div> & nbsp; </div>
<Div id = "Main">
<Div>
<H1> Lucky Draw Program <P> range: <input id = "f1" type = "text" size = "10" maxlength = "15" value = "100000" style = "border: 1px solid #000; "/>-<input id =" F2 "type =" text "size =" 10 "maxlength =" 15 "value =" 300000 "style =" border: 1px solid #000; "/> </P>
<P> result: <input id = "result" type = "text" size = "10" style = "height: 40px; width: 180px; Border: 1px solid red; font-size: 30; "readonly/> </P>
<Input id = "start" type = "button" value = "start" style = "border: 1px solid; border-color: # AAA 000 #000 # AAA; width: 4em; Background: # fc0; "onclick =" settimer () "/>
<Input id = "end" type = "button" value = "" style = "border: 1px solid; border-color: # AAA 000 #000 # AAA; width: 4em; Background: # fc0; "onclick =" cleartimer () "disabled/>
</Div>
</Div>
<Center>
</Body>
</Html>
Run: