User Tools

Site Tools


winnercode

Selecting a monthly winner.

A brief explanation of the selection process. Each participant is alotted a number when they enter the competition, at the end of the month I simply ask the following piece of code to generate a number.

Nobody entering the competition knows the number they are alotted when they enter, so they will gain nothing from trying to hack into and tweak the code here as the two systems are completely separate and have no relation to each other what so ever.

The selection process works simply by me entering the total number of participants - Then I click the on screen button and hey presto the webpage and the computer I am on generate the monthly winner for me.

Example code in case you wish to create a similar draw: (Shown example 4 contestants i.e. 25% chance to win)
<body>
<big><big><big><p id="demo">And the winner is......</p></big></big></big>
</BR>
<button onclick="myFunction()">Select Winner</button>
<script>
function myFunction()
{
document.getElementById("demo").innerHTML=Math.floor(Math.random() * 4) + 1;
}
</script>
</body>

Click the button to generate a random number.


And the winner is......


winnercode.txt · Last modified: 2013/02/04 10:52 by einarpetersen