Auto lotto dip : JavaScript DHTML examples (example source code) » GUI Components » Animation

JavaScript DHTML










Java Products
Java Articles
JavaScript DHTML Home  »   GUI Components   » [  Animation  ]   

 
Auto lotto dip

Please note that some example is only working under IE or Firefox.

// Lottery Number Picker - http://www.btinternet.com/~kurt.grigg/javascript

/*
Paste this link where you want the lottery picker to appear on your page.

<script type="text/javascript" src="straightlotto.js"></script>

To edit, right click on the straightlotto.js file icon and choose edit.

*/

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<title>Straight Lotto</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">



</head>
<body>




<script type="text/javascript">
// Lottery Number Picker - http://www.btinternet.com/~kurt.grigg/javascript

if ((document.getElementById && document.firstChild&& 
window.addEventListener || window.attachEvent){

(function(){

//Choose your lottery format here. 

var pick = 6;
var from = 1;
var to = 49;
var buttonText = "Lotto Lucky Dip";
var initialText = "Your Lucky Numbers";

//Scroll down to alter colours and size.

var playing = false;
var timer = null;
var counter = 0;

function numsort(n1,n2) {
if (n1 < n2x=-1;
else if (n1 > n2x=1;
else x=0;
return x;
}

function justOnce(b){
controlButton.blur();
if (playing){
 return false;
 }
else{
 lotto();
 }
}

function lotto(){
var rng = to-from;
var dum = "";
var e = (rng + 1);  
var draw = new Array();
var number;

if (from >= to ){
 alert("from value must be less than to value");
 return false;
 }
if ( (to+1)-from < pick){
 alert("Error - You want "+pick+" numbers.\n\n"     
 +"The range you have entered is from "+from+" to "+to+".\n"
 +"This leaves "+(rng+1)+" available random numbers.");
 return false;
 }

playing = true;
for (i=0; i < pick; i++){
number = parseInt(from + Math.random() * e);
 for (j=0; j < pick; j){
  if (number!=draw[j]){
   j++;
   }
  else{
   number = parseInt(from + Math.random() * e);
   j = 0
   }
  }
draw[i= number;
}

draw.sort(numsort);
for (i=0; i < pick; i++){
 disp = dum += (draw[i]+" ");
}
counter++;
document.getElementById("result"+idx).firstChild.data = disp;
timer = setTimeout(lotto,50);
if (counter > 50){
 clearTimeout(timer);
 playing=false;
 counter=0;
 }
}

var idx = document.getElementsByTagName('div').length;

//Alter the display style/looks here!
//Do not delete any commas etc!!

document.write('<div id="container'+idx+'" style="'
+'position:relative;'
+'width:160px;height:50px;'
+'font-family:verdana,arial,sans-serif;'
+'font-size:12px;'
+'color:#000000;'
+'background-color:#fffff0;'
+'text-align:center;'
+'border : 1px solid #000000">'
+'<input type="button" id="play'+idx+'"'
+'value="'+buttonText+'" style="margin:5px">'
+'<div id="result'+idx+'" style="'
+'width:150px;'
+'font-family:verdana,arial,sans-serif;'
+'font-size:12px;'
+'color:#000000">'+initialText+'<\/div><\/div>');

var controlButton = document.getElementById("play"+idx);
if (window.addEventListener){
 controlButton.addEventListener("click",justOnce,false);
}  
else if (window.attachEvent){
 controlButton.attachEvent("onclick",justOnce);


})();
}
</script>



</body>
</html>
Related examples in the same category
1.  Circle Animation
2.  Right to left animation
3.  Flash animation in Javascript
4.  Flash animation in JavaScript: Changing style Properties
5.  Animation along Straight Line
6.  Animation along a Circle
7.  Dancing Text (IE)
8.  Type Writer effect (IE)
9.  Type Writer Effect 1.1 (IE)
10.  JavaScript Ticker 1.2 (IE)
11.  Animation: Lottery Number Picker and Statistics
12.  Animation: wriggly
13.  Animation: welcome message
14.  Animation: trio
15.  Animation: snow
16.  Animation: star
17.  Animation: mouse doodle
18.  Animation: fireworks
19.  Animation: pretty
20.  Animation: Random Movement
21.  Lotto number draw
22.  Following eyes
23.  Animation: three eyes
24.  Animation: eyes
25.  Spot light
26.  Big static eyes
27.  Animation based on DIV with color flash
28.  Framework for creating CSS-based animations
29.  Animate dynamic element h1 tag
30.  Popup window animation (fly across screen)
31.  Animation on several images
32.  Using the onFilterChange Event Handler
33.  JavaScript Animation
34.  Periodically Updating the Text Displayed by an HTML Element
35.  Moving an Airplane Across a Web Page
36.  Link Hint Scroller 2.0 (IE)








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.