<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 < n2) x=-1; else if (n1 > n2) x=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.nn" +"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!!
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 Scripts with Example Source Code in same category :