Lottery programs written in Javascript

Source: Internet
Author: User

 

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:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.