User Tools

Site Tools


winnercode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

winnercode [2013/02/04 10:52] (current)
Line 1: Line 1:
 +====== 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.
 +
 +<code>
 +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>
 +</code>
 +-----
 +<fs xx-large>Click the button to generate a random number.</fs>
 +<HTML>
 +</BR>
 +<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() * 6) + 1;
 +}
 +</script>
 +</body>
 +</HTML>
winnercode.txt ยท Last modified: 2013/02/04 10:52 (external edit)