Several colleagues in a variety of requests, for them to write the sports Lottery random number generator program, using cookies.

Source: Internet
Author: User
Tags array generator sort
cookie| Program | Random <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Sports Lottery Draw </title>

<script language= "JavaScript" ><!--
/*-----------------------------------------------------
At the request of a few colleagues, wrote the program for them, and I never buy lottery tickets, do not understand.
But if you're really in the jackpot, don't forget to tell me. What are you afraid of me splitting your money?
I am not greedy, the most send me a classic music dish I am very happy!
By Jianglixin@163.net (hastily written, code messy collation) 2001.2.28
-------------------------------------------------------*/
function Setcookie ()
{
var Then = new Date ();
if (document.all.lucknum.innertext.length>20)
{
Then.settime (Then.gettime () + 1000*60*1000);
Document.cookie = "lastnum=" +document.all.lucknum.innertext+ "; expires=" + then.togmtstring ();
}
}


function GetCookie ()
{
var cookieheader = "lastnum=";
var beginposition = document.cookie.indexOf (Cookieheader);
var status=document.cookie.substring (beginposition + cookieheader.length);
Document.all.lastnum.innertext= "Last selected number for you:" +status;
}




function check (form)
{

if (form.inputname.value.length<1)
{Alert ("Please enter your name!") ");
Form.inputName.focus ();
return (false);

if (form.inputnum.value.length<1)
{Alert ("Please enter your birthday or lucky number!") ");
Form.inputNum.focus ();
return (false);

if (!) ( Checknum (Form.inputNum.value))
{Alert ("Lucky number must be number!") ");
Form.inputNum.focus ();
return (false);

var randnum,seeds,repeat;
var my_array = new Array ();
var test_array = new Array ();
var sort_array = new Array ();
Seeds=form.inputnum.value;
selectnum=7;totalnum=36;

for (i=0;i<totalnum;i++) sort_array[i]=i;

for (i=0;i<totalnum;i++) test_array[i]=0;


for (p=0;p<seeds;p++)
{


var i = 0;
while (i <7)
{
Repeat=false;
Randnum=math.ceil (Totalnum*math.random (seeds));

for (j=0;j<i;j++)
{
if (Randnum==my_array[j])
Repeat=true;
}

if (Repeat==false)
{
My_array[i]=randnum;
Test_array[randnum]+=1;
i++;
}

}
}


My_array sort
var temp;
for (i=0;i<selectnum-1;i++)
{
for (j=1;j<selectnum-i;j++)
{
if (My_array[i]>my_array[i+j])
{
Temp=my_array[i];
MY_ARRAY[I]=MY_ARRAY[I+J];
My_array[i+j]=temp;
}
}
}


Sort
var tempnum;
for (i=0;i<selectnum;i++)
{
for (j=1;j<totalnum-i;j++)
&nbs



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.