Mega Code Archive

 
Categories / JavaScript DHTML / GUI Components
 

Lotto number draw

/* Paste this style sheet to the head of your page or add its contents to an existing sheet. <style type="text/css"> <!-- a.kjg:link, a.kjg:visited, a.kjg:active{ color:#ffffff; text-decoration:none; } a.kjg:hover{ color:#cf5600; } input{ font-family : verdana,helvetica,sans-serif; font-size : 11px; color : #000000; } .blntxt{ position : relative; width : 500px; background-color : #cf5600; font-family : verdana,helvetica,sans-serif; font-size : 11px; color : #fffff0; } //--> </style> Paste this link to where you the game to appear on your page. <script type="text/javascript" src="bln.js"></script> Make sure the bln.js file is in/uploaded to the same directory/folder as the web page using it! */ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Better Lottery Numbers</title> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="content-script-type" content="text/javascript"> <meta http-equiv="content-style-type" content="text/css"> <style type="text/css"> <!-- a.kjg:link, a.kjg:visited, a.kjg:active{ color:#ffffff; text-decoration:none; } a.kjg:hover{ color:#cf5600; } input{ font-family : verdana,helvetica,sans-serif; font-size : 11px; color : #000000; } .blntxt{ position : relative; width : 500px; background-color : #cf5600; font-family : verdana,helvetica,sans-serif; font-size : 11px; color : #fffff0; } //--> </style> </head> <body> <script type="text/javascript"> function theGameHTML(){ Grigg_1=new Array(60,102,111,114,109,32,110,97,109,101,61,34,98,108,110,34,32,97,99, 116,105,111,110,61,34,34,62,13,10,60,116,97,98,108,101,32,99,101,108,108,112,97,100, 100,105,110,103,61,34,53,34,32,99,101,108,108,115,112,97,99,105,110,103,61,34,48,34, 32,99,108,97,115,115,61,34,98,108,110,116,120,116,34,32,115,116,121,108,101,61,34,98, 111,114,100,101,114,58,52,112,120,32,115,111,108,105,100,32,35,99,102,53,54,48,48,34, 62,60,116,114,62,60,116,100,32,115,116,121,108,101,61,34,116,101,120,116,45,97,108, 105,103,110,58,99,101,110,116,101,114,59,98,97,99,107,103,114,111,117,110,100,45,99, 111,108,111,114,58,35,99,102,56,52,48,48,34,62,60,115,112,97,110,32,115,116,121,108, 101,61,34,102,111,110,116,45,115,105,122,101,58,49,51,112,120,59,102,111,110,116,45, 119,101,105,103,104,116,58,98,111,108,100,34,62,13,10,66,101,116,116,101,114,32,76, 111,116,116,101,114,121,32,78,117,109,98,101,114,115,13,10,60,47,115,112,97,110,62, 60,98,114,47,62,13,10,83,116,97,110,100,97,114,100,32,102,111,114,109,97,116,58,32, 54,32,110,117,109,98,101,114,115,32,102,114,111,109,32,49,32,116,111,32,52,57,13,10, 60,112,62,60,97,32,99,108,97,115,115,61,34,107,106,103,34,32,104,114,101,102,61,34, 104,116,116,112,58,47,47,119,119,119,46,98,116,105,110,116,101,114,110,101,116,46,99, 111,109,47,126,107,117,114,116,46,103,114,105,103,103,47,106,97,118,97,115,99,114,105, 112,116,34,62,38,99,111,112,121,59,32,75,117,114,116,39,115,32,100,104,116,109,108,60, 47,97,62,32,38,110,98,115,112,59,32,38,110,98,115,112,59,32,38,110,98,115,112,59,32,60, 97,32,99,108,97,115,115,61,34,107,106,103,34,32,104,114,101,102,61,34,104,116,116,112, 58,47,47,119,119,119,46,98,116,105,110,116,101,114,110,101,116,46,99,111,109,47,126, 107,117,114,116,46,103,114,105,103,103,47,106,97,118,97,115,99,114,105,112,116,47,90, 105,112,115,47,98,108,110,46,122,105,112,34,62,13,10,68,111,119,110,108,111,97,100,32, 102,111,114,32,121,111,117,114,32,119,101,98,32,112,97,103,101,32,111,114,32,106,117, 115,116,32,116,111,32,112,108,97,121,32,111,102,102,45,108,105,110,101,13,10,60,47,97, 62,60,47,112,62,60,47,116,100,62,60,47,116,114,62,60,116,114,62,60,116,100,62,13,10, 68,111,110,39,116,32,119,97,115,116,101,32,116,105,109,101,32,97,110,100,32,109,111, 110,101,121,32,98,121,32,115,116,105,99,107,105,110,103,32,119,105,116,104,32,100,117, 100,32,108,111,116,116,101,114,121,32,110,117,109,98,101,114,115,46,32,13,10,70,105, 110,100,32,111,117,116,32,116,104,101,32,119,105,110,110,105,110,103,32,112,111,116, 101,110,116,105,97,108,32,111,102,32,121,111,117,114,32,110,117,109,98,101,114,115,32, 110,111,119,46,32,84,104,105,115,32,103,97,109,101,32,99,97,110,32,115,105,109,117,108, 97,116,101,32,121,101,97,114,115,32,111,102,32,13,10,112,108,97,121,32,98,121,32,99, 104,101,99,107,105,110,103,32,121,111,117,114,32,110,117,109,98,101,114,115,32,97,103, 97,105,110,115,116,32,97,110,32,105,110,102,105,110,105,116,101,32,110,117,109,98,101, 114,32,111,102,32,99,111,109,112,117,116,101,114,32,103,101,110,101,114,97,116,101,100, 32,108,111,116,116,101,114,121,32,100,114,97,119,115,46,32,13,10,60,112,32,115,116,121, 108,101,61,34,116,101,120,116,45,97,108,105,103,110,58,99,101,110,116,101,114,34,62,13, 10,84,111,32,112,108,97,121,44,32,101,110,116,101,114,32,121,111,117,114,32,115,105, 120,32,110,117,109,98,101,114,115,32,105,110,32,116,111,32,116,104,101,32,39,89,111, 117,114,32,78,117,109,98,101,114,115,39,32,98,111,120,32,97,110,100,32,99,108,105,99, 107,32,80,108,97,121,46,13,10,60,47,112,62,60,47,116,100,62,60,47,116,114,62,60,116, 114,62,60,116,100,32,115,116,121,108,101,61,34,98,97,99,107,103,114,111,117,110,100,45, 99,111,108,111,114,58,35,99,102,56,52,48,48,34,62,60,116,97,98,108,101,32,99,101,108, 108,112,97,100,100,105,110,103,61,34,53,34,32,99,101,108,108,115,112,97,99,105,110,103, 61,34,48,34,32,99,108,97,115,115,61,34,98,108,110,116,120,116,34,62,60,116,114,62,60, 116,100,32,99,111,108,115,112,97,110,61,34,50,34,32,115,116,121,108,101,61,34,116,101, 120,116,45,97,108,105,103,110,58,99,101,110,116,101,114,59,98,97,99,107,103,114,111, 117,110,100,45,99,111,108,111,114,58,35,99,102,56,52,48,48,34,62,13,10,89,111,117,114, 32,78,117,109,98,101,114,115,13,10,60,98,114,47,62,60,105,110,112,117,116,32,110,97, 109,101,61,34,117,115,101,114,34,32,116,121,112,101,61,34,116,101,120,116,34,32,115, 105,122,101,61,34,49,55,34,32,109,97,120,108,101,110,103,116,104,61,34,49,55,34,32, 111,110,102,111,99,117,115,61,34,109,105,115,99,104,105,101,102,95,49,40,41,34,32,118, 97,108,117,101,61,34,34,62,60,98,114,47,62,60,47,116,100,62,60,116,100,32,114,111,119, 115,112,97,110,61,34,51,34,32,115,116,121,108,101,61,34,119,105,100,116,104,58,52,48, 48,112,120,59,116,101,120,116,45,97,108,105,103,110,58,108,101,102,116,34,62,13,10,87, 111,110,32,60,105,110,112,117,116,32,110,97,109,101,61,34,102,54,34,32,116,121,112,101, 61,34,116,101,120,116,34,32,115,105,122,101,61,34,53,34,32,111,110,102,111,99,117,115, 61,34,109,105,115,99,104,105,101,102,95,51,40,41,34,32,118,97,108,117,101,61,34,48,34, 62,32,116,105,109,101,115,46,32,77,97,116,99,104,32,54,32,119,105,110,115,32,163,51,44, 48,48,48,44,48,48,48,43,60,98,114,47,62,32,13,10,87,111,110,32,60,105,110,112,117,116, 32,110,97,109,101,61,34,102,53,97,34,32,116,121,112,101,61,34,116,101,120,116,34,32, 115,105,122,101,61,34,53,34,32,111,110,102,111,99,117,115,61,34,109,105,115,99,104,105, 101,102,95,51,40,41,34,32,118,97,108,117,101,61,34,48,34,62,32,116,105,109,101,115,46, 32,77,97,116,99,104,32,53,32,43,32,98,111,110,117,115,32,119,105,110,115,32,163,49,53, 48,44,48,48,48,43,60,98,114,47,62,13,10,87,111,110,32,60,105,110,112,117,116,32,110,97, 109,101,61,34,102,53,34,32,116,121,112,101,61,34,116,101,120,116,34,32,115,105,122,101, 61,34,53,34,32,111,110,102,111,99,117,115,61,34,109,105,115,99,104,105,101,102,95,51, 40,41,34,32,118,97,108,117,101,61,34,48,34,62,32,116,105,109,101,115,46,32,77,97,116, 99,104,32,53,32,119,105,110,115,32,163,50,48,48,48,43,60,98,114,47,62,13,10,87,111,110, 32,60,105,110,112,117,116,32,110,97,109,101,61,34,102,52,34,32,116,121,112,101,61,34, 116,101,120,116,34,32,115,105,122,101,61,34,53,34,32,111,110,102,111,99,117,115,61,34, 109,105,115,99,104,105,101,102,95,51,40,41,34,32,118,97,108,117,101,61,34,48,34,62,32, 116,105,109,101,115,46,32,77,97,116,99,104,32,52,32,119,105,110,115,32,163,52,57,43,60, 98,114,47,62,13,10,87,111,110,32,60,105,110,112,117,116,32,110,97,109,101,61,34,102,51, 34,32,116,121,112,101,61,34,116,101,120,116,34,32,115,105,122,101,61,34,53,34,32,111, 110,102,111,99,117,115,61,34,109,105,115,99,104,105,101,102,95,51,40,41,34,32,118,97, 108,117,101,61,34,48,34,62,32,116,105,109,101,115,46,32,77,97,116,99,104,32,51,32,119, 105,110,115,32,163,49,48,13,10,60,112,62,13,10,89,111,117,32,109,97,116,99,104,101,100, 32,60,105,110,112,117,116,32,110,97,109,101,61,34,99,117,114,114,34,32,116,121,112,101, 61,34,116,101,120,116,34,32,115,105,122,101,61,34,49,34,32,111,110,102,111,99,117,115, 61,34,109,105,115,99,104,105,101,102,95,51,40,41,34,32,118,97,108,117,101,61,34,34,62, 32,110,117,109,98,101,114,115,32,102,111,114,32,99,117,114,114,101,110,116,32,100,114, 97,119,46,32,13,10,60,47,112,62,60,105,110,112,117,116,32,110,97,109,101,61,34,112,108, 121,34,32,116,121,112,101,61,34,98,117,116,116,111,110,34,32,118,97,108,117,101,61,34, 80,108,97,121,34,32,111,110,99,108,105,99,107,61,34,109,105,115,99,104,105,101,102,95, 50,40,41,34,62,32,60,105,110,112,117,116,32,116,121,112,101,61,34,98,117,116,116,111, 110,34,32,118,97,108,117,101,61,34,82,101,115,101,116,34,32,111,110,99,108,105,99,107, 61,34,114,115,116,40,41,34,62,13,10,38,110,98,115,112,59,38,110,98,115,112,59,68,114, 97,119,32,115,112,101,101,100,32,13,10,60,115,101,108,101,99,116,32,110,97,109,101,61, 34,115,112,101,101,100,34,32,111,110,99,104,97,110,103,101,61,34,110,101,119,115,112, 101,101,100,40,116,104,105,115,41,34,62,13,10,60,111,112,116,105,111,110,32,118,97,108, 117,101,61,49,48,62,102,97,115,116,101,115,116,60,47,111,112,116,105,111,110,62,13,10, 60,111,112,116,105,111,110,32,118,97,108,117,101,61,53,48,48,62,102,97,115,116,60,47, 111,112,116,105,111,110,62,13,10,60,111,112,116,105,111,110,32,118,97,108,117,101,61, 49,48,48,48,32,115,101,108,101,99,116,101,100,62,109,101,100,105,117,109,13,10,60,111, 112,116,105,111,110,32,118,97,108,117,101,61,50,48,48,48,62,115,108,111,119,60,47,111, 112,116,105,111,110,62,13,10,60,111,112,116,105,111,110,32,118,97,108,117,101,61,51,48, 48,48,62,115,108,111,119,101,115,116,60,47,111,112,116,105,111,110,62,13,10,60,47,115, 101,108,101,99,116,62,60,47,116,100,62,60,47,116,114,62,60,116,114,62,60,116,100,32,99, 111,108,115,112,97,110,61,34,50,34,32,115,116,121,108,101,61,34,116,101,120,116,45,97, 108,105,103,110,58,99,101,110,116,101,114,59,98,97,99,107,103,114,111,117,110,100,45, 99,111,108,111,114,58,35,99,102,56,52,48,48,34,62,13,10,84,104,101,32,76,111,116,116, 101,114,121,32,78,117,109,98,101,114,115,13,10,60,98,114,47,62,60,105,110,112,117,116, 32,110,97,109,101,61,34,102,34,32,116,121,112,101,61,34,116,101,120,116,34,32,115,105, 122,101,61,34,49,55,34,32,111,110,102,111,99,117,115,61,34,109,105,115,99,104,105,101, 102,95,51,40,41,34,32,118,97,108,117,101,61,34,34,62,60,98,114,47,62,13,10,66,111,110, 117,115,32,66,97,108,108,13,10,60,98,114,47,62,60,105,110,112,117,116,32,110,97,109, 101,61,34,98,34,32,116,121,112,101,61,34,116,101,120,116,34,32,115,105,122,101,61,34, 50,34,32,111,110,102,111,99,117,115,61,34,109,105,115,99,104,105,101,102,95,51,40,41, 34,32,118,97,108,117,101,61,34,34,62,60,47,116,100,62,60,47,116,114,62,60,116,114,62, 13,10,60,116,100,32,115,116,121,108,101,61,34,116,101,120,116,45,97,108,105,103,110, 58,99,101,110,116,101,114,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111, 114,58,35,99,102,56,52,48,48,34,62,13,10,163,39,115,32,115,112,101,110,116,13,10,60, 98,114,47,62,60,105,110,112,117,116,32,110,97,109,101,61,34,102,99,34,32,116,121,112, 101,61,34,116,101,120,116,34,32,115,105,122,101,61,34,56,34,32,111,110,102,111,99,117, 115,61,34,109,105,115,99,104,105,101,102,95,51,40,41,34,32,118,97,108,117,101,61,34,48, 34,62,60,47,116,100,62,60,116,100,32,115,116,121,108,101,61,34,116,101,120,116,45,97, 108,105,103,110,58,99,101,110,116,101,114,59,98,97,99,107,103,114,111,117,110,100,45, 99,111,108,111,114,58,35,99,102,56,52,48,48,34,62,13,10,163,39,115,32,119,111,110,13, 10,60,98,114,47,62,60,105,110,112,117,116,32,110,97,109,101,61,34,102,119,34,32,116, 121,112,101,61,34,116,101,120,116,34,32,115,105,122,101,61,34,56,34,32,111,110,102,111, 99,117,115,61,34,109,105,115,99,104,105,101,102,95,51,40,41,34,32,118,97,108,117,101, 61,34,48,34,62,60,47,116,100,62,60,47,116,114,62,60,47,116,97,98,108,101,62,60,47,116, 100,62,60,47,116,114,62,60,116,114,62,60,116,100,62,13,10,87,97,114,110,105,110,103,33, 32,83,117,112,101,114,115,116,105,116,105,111,117,115,32,116,121,112,101,115,46,32,87, 105,110,110,105,110,103,32,116,104,101,32,106,97,99,107,112,111,116,32,105,115,32,49, 52,44,48,48,48,44,48,48,48,32,116,111,32,49,46,32,73,102,32,121,111,117,32,119,105,110, 32,105,116,32,104,101,114,101,32,102,111,114,32,110,111,116,104,105,110,103,44,32,121, 111,117,39,118,101,32,13,10,112,114,111,98,97,98,108,121,32,98,108,111,119,110,32,121, 111,117,114,32,111,110,108,121,44,32,105,102,32,97,110,121,44,32,99,104,97,110,99,101, 32,111,102,32,100,111,105,110,103,32,105,116,32,97,103,97,105,110,32,102,111,114,32, 114,101,97,108,33,13,10,60,47,116,100,62,60,47,116,114,62,60,47,116,97,98,108,101,62, 60,47,102,111,114,109,62); var the_code; dum = ""; Grigg_2 = new Array(); for (i=0; i < Grigg_1.length; i++){ Grigg_2[i] = String.fromCharCode(Grigg_1[i]); the_code=dum+=Grigg_2[i]; } document.write(the_code); } theGameHTML(); var bln = document.bln; var timer = null; var _3 = 0; var _4 = 0; var _5 = 0; var _5a = 0; var _6 = 0; var count = 0; var won = 0; var d4; var playing = false; var bonus = false; function mischief_1(){ if (playing){  bln.ply.focus();  alert("In progress:\nMust click reset to change numbers.\nReturning to game....");  bln.user.value = user_disp;  } } function mischief_2(){  if (playing){    alert("Already playing.....");   return false;  }  else{   usercheck();  } } function mischief_3(){  if (playing){  bln.ply.focus();  } } function usercheck(){ d1 = bln.user.value; d1a = bln.user;  //Numbers only.  for (i=0; i < d1.length; i++){  var tmpd1 = d1.substring(i, i + 1);         if ((tmpd1 < "0" || "9" < tmpd1) && tmpd1 != " "){    alert("Numbers only.");    d1a.focus();    d1a.select();    return false;   }   }  //Strip all initial space.  c1 = 0;  for (i=0; i < d1.length; i++){   if (d1.charAt(i) != " "){    break;   }   else{    c1++;   }  } d1 = d1.substring(c1,d1.length);  //Strip all inner spaces except 1.  d2 = d1.split("");  d3 = "";  for (i=0; i < d2.length; i++){   if ((d2[i+1]==" ") && (d2[i+2]==" ")){   d2[i+1]="";   }  d3 += (d2[i]);  }  //Strip all end spaces.  d3 = d3.substring(0,d3.length);  if (d3.charAt(d3.length-1) == " "){  d3=d3.substring(0,d3.length-1);  }  bln.user.value=d3;  //Check if empty.  if (d3.length == 0){   alert("Enter your numbers first.");  d1a.focus();  return false;  }  //Check for 6 nums only.  d4 = d3.split(" ");  if (d4.length != 6){   alert("You must pick 6 numbers. You have picked "+d4.length+".");  d1a.focus();  d1a.select();  return false;  }  //Check range.  for (i=0; i < d4.length; i++){   if ((d4[i] < 1 || d4[i] > 49)){   alert("Pick numbers 1 to 49 only.");   d1a.focus();   d1a.select();   return false;   }  }  //Strip leading zeros.  cnt1 = new Array();  for (i=0; i < d4.length; i++){   cnt1[i]=-1;  }   for (i=0; i < d4.length; i++){    for (j=0; j < d4[i].length; j++){     if ((d4[i].substring(0,j) == 0)){      cnt1[i]++;     }    }   }  for (i=0; i < d4.length; i++){  d4[i] = d4[i].substring(cnt1[i],d4[i].length);  d4[i]=parseInt(d4[i]);  }  d4.sort(numsort);  user_disp = "";  for (i=0; i < d4.length; i++){  user_disp+=d4[i]+" ";  }  bln.user.value=user_disp;  //Check for same numbers.  for (i=0; i < d4.length; i++){   for (j=0; j < d4.length; j++){    if (j != i){     if (d4[i] == d4[j]){     alert("Each number must be different");     d1a.focus();     d1a.select();     return false;     }    }   }  }  if (confirm("Happy with your numbers?")){  lotto();  }  else{  d1a.focus();  d1a.select();  } }//End func. function numsort(n1,n2) { if (n1<n2) v=-1; else if (n1>n2) v=1; else v=0; return v; } function rst(){ if (playing)clearTimeout(timer); bonus=false; playing=false; user_disp=""; _3=0; _4=0; _5=0; _5a=0; _6=0; count=0; won=0; bln.user.value=""; bln.f.value=""; bln.b.value=""; bln.fc.value=0; bln.fw.value=0; bln.f6.value=0; bln.f5a.value=0; bln.f5.value=0; bln.f4.value=0; bln.f3.value=0; bln.curr.value=""; } rst(); var spd = 1000; function newspeed(x){ spd = x.options[x.selectedIndex].value; } function lotto(){ playing = true; bonus = false; var find = 0; var dum1 = ""; var nums = new Array(); for (i=0; i < 6; i++){ r_nums = parseInt(1 + Math.random() * 49);  for (j=0; j < 6; j){   if (r_nums != nums[j]) j++;   else{    r_nums = parseInt(1 + Math.random() * 49);    j=0;   }  } nums[i]=r_nums; } nums.sort(numsort); //Get bonus ball. b_ball=Math.round(1+Math.random()*48); for (j=0; j < 6; j){  if (b_ball!=nums[j]){  j++;  }  else{  b_ball=Math.round(1+Math.random()*48);  j=0;  } }  //For display only.  t_nums = nums.toString();  t_nums = t_nums.split(',');  for (i=0; i < t_nums.length; i++){   t_nums[i] = t_nums[i]+' ';   disp_nums = dum1+=t_nums[i];  }  bln.f.value=disp_nums;  bln.b.value=b_ball; timer = setTimeout("lotto()",spd);  for (i=0; i < 6; i++){   if (b_ball == d4[i]){   bonus=true;   }   for (j=0; j < 6; j++){    if (nums[i] == d4[j]){    find++;    }   }  } if (find == 6){won+=3000000;_6++;alert("Jackpot.\nGame over.");clearTimeout(timer)} if (find == 5 && bonus){won+=150000;_5a++} if (find == 5){won+=2000;_5++} if (find == 4){won+=49;_4++} if (find == 3){won+=10;_3++} count++; bln.fc.value = count; bln.fw.value = won; bln.f6.value = _6; bln.f5a.value = _5a; bln.f5.value = _5; bln.f4.value = _4; bln.f3.value = _3; bln.curr.value = find; } </script> </body> </html>