Flip a Coin all editions

Flip a Coin 7th edition (click here to see the blog post)

<!DOCTYPE HTML>

<html>

<body bgcolor=B0E0E6 onload= "timeCount()">

<center>

<font>

Click on the picture to flip a coin.<br>

The default coin has 2 sides (head and tail).<br>

You can change the coin!<br>

Any number greater than 2 makes the coin with three sides: head, tail, and rim.<br>

The rim has only one chance out of the given number you put in the box "Odds".<br>

</font>

<script type="text/javascript">

/* Flip a Coin 7

Author: Michael Langerman. 2013

www.fewdoit.com

email: fewdoit@gmail.com

Many thanks to www.javascript.ru; www.w3schools.com; www.javascriptsource.com and all people supporting open internet.

Thanks everone for sharing your knowledge and expertise.

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See <http://www.gnu.org/licenses/>.

*/

var seconds = 0;

var minutes = 0;

var hours = 0;

var intervalSeconds;

var timerIsOn = 0;

function timeCount()

{

seconds = seconds + 1;

intervalSeconds = setTimeout("timeCount()", 1000);

document.getElementById("time").value = hours + ":" + minutes + ":" + seconds;

if (seconds >= 60)

{

minutes = Math.floor (seconds / 60) + minutes;

seconds %= 60;

}

if (minutes >= 60)

{

hours = Math.floor (minutes / 60) + hours;

minutes %= 60;

}

}

function playTimer()//activates when user clicks on the "Play" button.

{

if ( ! timerIsOn)//check if the user clicks one time on the "Play" button-to avoid many timers at the same time.

{

timerIsOn = 1;

timeCount();

}

}

function stopTimer()//activates when user clicks on the "Pause" button.

{

clearTimeout(intervalSeconds);

timerIsOn = 0;

}

var headScore= 0;

var tailScore= 0;

var rimScore= 0;

var totalScore=0;

function resetAll(){

headScore=0;

document.getElementById("totalHeads").value= headScore;

tailScore=0;

document.getElementById("totalTails").value= tailScore;

rimScore=0;

document.getElementById("totalRims").value= rimScore;

totalScore=0;

document.getElementById("totalScores").value= totalScore ;

document.getElementById("odds").value= 2 ;

}

var odds;// retrives the user defined odds number from input box

function spinning(){

odds=document.getElementById("odds").value;

document.getElementById("b1").src ="https://lh6.googleusercontent.com/-I_wGgaRpsbw/UH4T17o4ccI/AAAAAAAAK5w/0ZNDzzUmyts/s108/one%2520dream%2520coin%25203%2520animated%2520vertical%2520108.gif";

var t=setTimeout("flip()",1000); // it shows animated picture for 1 sec and then calls function flip ()

}

function flip(){

if (odds==2){

flip2();

}

else if (odds>=3){

flipAny();

}

else{

alert("You know the answer! "+odds+" is an incorrect input. Please change the Odds.");

document.getElementById("b1").src ="https://lh6.googleusercontent.com/-6lBiMqn-BRw/UGnyiMGk86I/AAAAAAAAKvc/DKV4hCd5df4/s108/one%2520dream%2520coin%25203%2520stuck%2520108.gif";

}

}

function flip2(){

var randomNumber = (Math.floor(Math.random()*2));

if (randomNumber==0){

document.getElementById("b1").src ="https://lh5.googleusercontent.com/-UOOuuHlwi8c/UF_KJpkbi5I/AAAAAAAAKuM/bHC5SJMiL-s/s108/one%2520dream%2520coin%25203%2520head%2520108.gif";

headScore=headScore+1;

document.getElementById("totalHeads").value= headScore ; //output the total score of heads

}

else if (randomNumber==1){

document.getElementById("b1").src ="https://lh3.googleusercontent.com/--j5P4V9hLFo/UF_KJ0V4RTI/AAAAAAAAKuU/8Ob4V1WdiNk/s108/one%2520dream%2520coin%25203%2520tail%2520108";

tailScore=tailScore+1;

document.getElementById("totalTails").value= tailScore ; //output the total score of tails

}

else{

document.getElementById("b1").src ="https://lh6.googleusercontent.com/-6lBiMqn-BRw/UGnyiMGk86I/AAAAAAAAKvc/DKV4hCd5df4/s108/one%2520dream%2520coin%25203%2520stuck%2520108.gif";

rimScore=rimScore+1;

document.getElementById("totalRims").value= rimScore ; //output the total score of rims

}

{

document.getElementById("totalScores").value=headScore + tailScore + rimScore; //output the total scores

}

}

function flipAny(){

var stuckNumber= odds/2^0;// divide odds number on two to define the number to use for the stuck coin

var randomNumber = (Math.floor(Math.random()*odds)) //It generates random number based on the odds number.

if (randomNumber<stuckNumber){

document.getElementById("b1").src ="https://lh5.googleusercontent.com/-UOOuuHlwi8c/UF_KJpkbi5I/AAAAAAAAKuM/bHC5SJMiL-s/s108/one%2520dream%2520coin%25203%2520head%2520108.gif";

headScore=headScore+1;

document.getElementById("totalHeads").value= headScore ; //output the total score of heads

}

else if (randomNumber>stuckNumber){

document.getElementById("b1").src ="https://lh3.googleusercontent.com/--j5P4V9hLFo/UF_KJ0V4RTI/AAAAAAAAKuU/8Ob4V1WdiNk/s108/one%2520dream%2520coin%25203%2520tail%2520108";

tailScore=tailScore+1;

document.getElementById("totalTails").value= tailScore ; //output the total score of tails

}

else{

document.getElementById("b1").src ="https://lh6.googleusercontent.com/-6lBiMqn-BRw/UGnyiMGk86I/AAAAAAAAKvc/DKV4hCd5df4/s108/one%2520dream%2520coin%25203%2520stuck%2520108.gif";

rimScore=rimScore+1;

document.getElementById("totalRims").value= rimScore ; //output the total score of rims

}

{

document.getElementById("totalScores").value=headScore + tailScore + rimScore; //output the total scores

}

}

</script>

<img border="0" alt="Visit www.fewdoit.com" src="https://lh5.googleusercontent.com/-UOOuuHlwi8c/UF_KJpkbi5I/AAAAAAAAKuM/bHC5SJMiL-s/s108/one%2520dream%2520coin%25203%2520head%2520108.gif" id="b1" onclick="spinning()"/></a>

<table border="1">

<tr>

<th>Side of the coin</th>

<th>Totals:</th>

</tr>

<tr>

<td>Head</td>

<td><output name="totalHeads" size=5 id="totalHeads"></output></td>

</tr>

<tr>

<td>Tail</td>

<td><output name="totalTails" size=5 id="totalTails"></output></td>

</tr>

<tr>

<td>Rim</td>

<td><output name="totalRims" size=5 id="totalRims"></output></td>

</tr>

<tr>

<td>All sides</td>

<td><output name="totalScores" size=5 id="totalScores"></output></td>

</tr>

<tr>

<td>Odds. Change the number and click the picture. </td>

<td>1 out of <input name="odds" value=2 size=5 id="odds"/></td>

</tr>

<tr>

<td></td>

<td><input onclick="resetAll()" type="button" value="Reset all!" /></td>

</table>

<br>

So far you spent <output id="time" size="6" type="text"></output> on this page.<br />

<input onclick="stopTimer()" type="button" value="Pause" />

<input onclick="playTimer()" type="button" value="Play" /><br />

<a href="http://www.fewdoit.com/">www.fewdoit.com</a><br />

for you

</center>

</body>

<br />

<div style="text-align: center;">

<img src="http://4.bp.blogspot.com/--j5P4V9hLFo/UF_KJ0V4RTI/AAAAAAAAKuU/8Ob4V1WdiNk/s108/one%2520dream%2520coin%25203%2520tail%2520108.gif" />

</html>

Flip a Coin 6th edition (click here to see blogpost)

<html>

<center>

<font>

In this example odds are that coin stucks on rim one time out of 21.<br>

If your coin has stuck on a rim...take a break :)<br>

Click on the picture to flip a coin</font>

<script type="text/javascript">

/* Flip a Coin 6

Author: Michael Langerman. 2012

www.fewdoit.com

email: fewdoit@gmail.com

Many thanks to www.w3schools.com , www.javascriptsource.com and all people supporting free open

internet comunity with free tutorials and references.

Thanky everone for sharing your knowledge and expertise.

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See <http://www.gnu.org/licenses/>.

*/

var sec=0;

var intervalSeconds;

function timeCount()

{

document.getElementById("time").value=sec;//output the time (in seconds) in the text box

sec=sec+1;//adds one to the current time

intervalSeconds=setTimeout("timeCount()",1000);//sets interval to one second (1000 millesecond)

}

//End of the timer script

var headScore= 0;

var tailScore= 0;

var rimScore= 0;

var totalScore=0;//total score for all flips

function spinning()

{

document.getElementById("b1").src ="https://lh3.googleusercontent.com/-D1Pkx1q-_4c/UF_V951k7GI/AAAAAAAAKuw/og-Taazv54E/s108/one%2520dream%2520coin%25203%2520animated%2520108.gif";

var t=setTimeout("flip()",1000); // it shows animated picture for 1 sec and then calls function flip ();

}

function flip()

{

var randomNumber = (Math.floor(Math.random()*21)) //It generates random number 0 to 19, based on the results it shows one of 3 pictures, with odds 1/21 that coin is stuck;

if (randomNumber<=9)

{

document.getElementById("b1").src ="https://lh5.googleusercontent.com/-UOOuuHlwi8c/UF_KJpkbi5I/AAAAAAAAKuM/bHC5SJMiL-s/s108/one%2520dream%2520coin%25203%2520head%2520108.gif";

headScore=headScore+1;

document.getElementById('totalHeads').value= headScore ; //output the total score of heads

}

else if (randomNumber>=11)

{

document.getElementById("b1").src ="https://lh3.googleusercontent.com/--j5P4V9hLFo/UF_KJ0V4RTI/AAAAAAAAKuU/8Ob4V1WdiNk/s108/one%2520dream%2520coin%25203%2520tail%2520108.gif";

tailScore=tailScore+1;

document.getElementById('totalTails').value= tailScore ; //output the total score of tails

}

else

{

document.getElementById("b1").src ="https://lh6.googleusercontent.com/-6lBiMqn-BRw/UGnyiMGk86I/AAAAAAAAKvc/DKV4hCd5df4/s108/one%2520dream%2520coin%25203%2520stuck%2520108.gif";

rimScore=rimScore+1;

document.getElementById("totalRims").value= rimScore ; //output the total score of rims

}

{

document.getElementById("totalScores").value=headScore + tailScore + rimScore; //output the total scores

}

}

</script>

</center><p>

<body bgcolor=B0E0E6 onload= "timeCount()"><!-- initiatets timer function-->

<center><p>

<img border="0" alt="Visit www.fewdoit.com" src="https://lh5.googleusercontent.com/-UOOuuHlwi8c/UF_KJpkbi5I/AAAAAAAAKuM/bHC5SJMiL-s/s108/one%2520dream%2520coin%25203%2520head%2520108.gif" id="b1" onclick="spinning()"/></a>

<form>

<table border="1">

<tr>

<th>Side of the coin</th>

<th>Totals:</th>

</tr>

<tr>

<td>Head</td>

<td><input type="text" size=5 id="totalHeads"></td>

</tr>

<tr>

<td>Tail</td>

<td><input type="text" size=5 id="totalTails"></td>

</tr>

<tr>

<td>Rim</td>

<td><input type="text" size=5 id="totalRims"></td>

</tr>

<tr>

<td>All sides</td>

<td><input type="text" size=5 id="totalScores"></td>

</tr>

</table>

So far you wasted (or maybe not?!)<input type="text" size=5 id="time">seconds on this page.

</form>

<font> <a href="http://www.fewdoit.com">www.fewdoit.com</a><br>

for you</font>

</center><p>

</html>

Flip a Coin 5th edition (click here to see on blog)

<html>

<head>

<center>

<font>

In this example odds are that coin stucks on rim one time out of 21.<br>

If your coin has stuck on a rim...take a break :)<br>

<br>

Click on the picture to flip a coin<br>

</font>

<script type="text/javascript">

/* Flip a Coin 5

Author: Michael Langerman. 2012

www.fewdoit.com

email: fewdoit@gmail.com

Many thanks to www.w3schools.com , www.javascriptsource.com and all people supporting free open

internet comunity with free tutorials and references.

Thanky everone for sharing your knowledge and expertise.

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See <http://www.gnu.org/licenses/>.

*/

<!--

function spinning()

{

document.getElementById("b1").src ="https://lh6.googleusercontent.com/-P1vQo1SHM_4/UFScmOYd-oI/AAAAAAAAKik/-4Uv0PyzG3M/s450/one%2520dream%2520coin%2520spinning.gif";

var t=setTimeout("flip()",1000); // it shows picture for 2 sec and then calls function flip ();

}

function flip()

{

var randomNumber = (Math.floor(Math.random()*21)) //It generates random number 0 to 19, based on the results it shows one of 3 pictures, with odds 1/21 that coin is stuck;

if (randomNumber<=9)

{

document.getElementById("b1").src ="https://lh5.googleusercontent.com/-k1LP-tZDFIw/UFOKCfx4xdI/AAAAAAAAKhU/ic8IWH_bFEE/s450/1%2520one%2520dream%2520coin%2520side%2520A%2520head.gif";

}

else if (randomNumber>=11)

{

document.getElementById("b1").src ="https://lh4.googleusercontent.com/-DGcmMFBuc6U/UFOKDB3IIPI/AAAAAAAAKhs/9XeKWaj4jqc/s450/4%2520one%2520dream%2520coin%2520side%2520B%2520tail.gif";

}

else

{

document.getElementById("b1").src ="https://lh5.googleusercontent.com/-LJpbGEfsCII/UFOKEDrhCeI/AAAAAAAAKiE/8WTuBtevHMM/s450/coin-is-stuck.gif";

}

}

//-->

</script>

</center><p>

</head>

<body>

<center><p>

<img border="0" alt="Visit www.fewdoit.com" src="https://lh4.googleusercontent.com/-D1uBqNESGwI/UFOKEsgeaXI/AAAAAAAAKiU/uBRQc4dV5P4/s450/question%2520mark.gif" id="b1"

onclick="spinning()" /></a>

</body><br>

<body bgcolor=B0E0E6>

<font> <a href="http://www.fewdoit.com">www.fewdoit.com</a> <br>

for you</font>

</center><p>

</html>

Flip a Coin 4 (click here to see on blog)

<html>

<head>

<center>

<font>

In this example odds are that coin stucks on rim one time out of 21.<br>

If your coin has stuck on a rim...take a break :)<br>

<br>

Move mouse over the picture to flip a coin<br>

Click on the picture to read about One Dream Project<br>

</font>

<script type="text/javascript">

/* Flip a Coin 4

Author: Michael Langerman. 2012

www.fewdoit.com

email: fewdoit@gmail.com

Many thanks to www.w3schools.com , www.javascriptsource.com and all people supporting free open

internet comunity with free tutorials and references.

Thanky everone for sharing your knowledge and expertise.

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See <http://www.gnu.org/licenses/>.

*/

<!--

function flip() { //function flip() runs everytime you move mouse over picture of coin.

var randomNumber = (Math.floor(Math.random()*21)) //It generates random number 0 to 19, and the odds is one of 21 that the coin stucks on rim;

if (randomNumber<=9)

{

document.getElementById("b1").src ="http://3.bp.blogspot.com/-XTFXGPdvXx4/UEi1S5_lzUI/AAAAAAAAKf0/5FY6flYiVzM/s320/1+one+dream+coin+side+A+300.jpg";

}

else if (randomNumber>=11)

{

document.getElementById("b1").src ="http://1.bp.blogspot.com/-ctFLSFZk9Rs/UEi1T9zY9sI/AAAAAAAAKgI/DkachHu0cjU/s320/4+one+dream+coin+side+B+300.jpg";

}

else

{

document.getElementById("b1").src ="http://2.bp.blogspot.com/-YHMPjTyx1Zw/UEkcAH7RJaI/AAAAAAAAKhE/n4i0YIUusFU/s320/one+dream+coin+stuck.jpg";

}

}

//-->

function mouseOut() //function mouseOut () runs everytime you move mouse out away from the coin.

{

document.getElementById("b1").src="http://3.bp.blogspot.com/-Ql-epzVm04c/UEi1Wr14ELI/AAAAAAAAKgw/jmAvPfayElg/s320/question+mark.jpg";

}

</script>

</head>

<body>

<a href="http://www.fewdoit.com/" target="_blank">

<img border="0" alt="Visit www.fewdoit.com" src="http://3.bp.blogspot.com/-Ql-epzVm04c/UEi1Wr14ELI/AAAAAAAAKgw/jmAvPfayElg/s320/question+mark.jpg" id="b1"

onmouseover="flip()" onmouseout="mouseOut()" /></a>

</body><br>

<body bgcolor=B0E0E6>

<font> <a href="http://www.fewdoit.com">www.fewdoit.com</a> <br>

for you</font>

</center><p>

</html>

Flip a Coin 3 (click here to see on blog)

<html>

<body bgcolor=B0E0E6>

<center>

<font> There is one very odd chance that your coin may stuck on a rim.<br>

In this example I reduced the odds to one out of 21.<br>

If your coin has stuck on a rim...take a break :) </font>

<form name=myForm>

<table border=3 cellpadding=1>

<td align=middle>

<input type=button value="Flip a Coin" name=button onclick="flip()">

<input type=text size=15 name=text>

</td>

</table>

</form>

</center>

<p><center>

<font> <a href="http://www.fewdoit.com">www.fewdoit.com</a> <br>

for you</font>

</center><p>

<script type="text/javascript">

/* Flip a Coin 3

Author: Michael Langerman. 2012

www.fewdoit.com

email: fewdoit@gmail.com

Many thanks to www.w3schools.com , www.javascriptsource.com and all people supporting free open

internet comunity with free tutorials and references.

Thanks for sharing your knowledge and expertise.

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See <http://www.gnu.org/licenses/>.

*/

<!--

function flip() { //function flip() runs everytime you click a button.

var randomNumber = (Math.floor(Math.random()*21)) //It generates random number 0 to 19,coin stucks on rim one chanse of 21;

if (randomNumber<=9)

{

document.myForm.text.value = "Head";

}

else if (randomNumber>=11)

{

document.myForm.text.value = "Tail";

}

else

{

document.myForm.text.value = "Coin stuck on rim";

}

}

//-->

</script>

</html>

Flip a Coin 2 (click here to see on blog)

<html>

<body bgcolor=lightblue>

<center>

<form name=myForm>

<table border=3 cellpadding=1>

<td align=middle>

<input type=button value="Flip a Coin" name=button onclick="flip()">

<input type=text size=5 name=text>

</td>

</table>

</form>

</center>

<p><center>

<font> <a href="http://www.fewdoit.com">www.fewdoit.com</a> <br>

for you</font>

</center><p>

<script type="text/javascript">

/* Flip a Coin 2

Author: Michael Langerman. 2012

www.fewdoit.com

email: fewdoit@gmail.com

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See <http://www.gnu.org/licenses/>.

*/

<!--

function flip() { //function flip() runs everytime you click a button.

var randomNumber=(Math.floor(Math.random()*2)); //It generates random number 0 to 1;

display=(randomNumber=="0")?"Head":"Tail"; //if the var "display" is "0" it prints "Head", if var "display" is "1" it prints "Tail"

document.myForm.text.value = display;

}

//-->

</script>

</html>

Flip a Coin 1 (click here to see on blog)

<html>

<body>

<p>Flip Coin.

<br>New side of the coin shows every time you open or refresh this page.

<br>Your side of the coin:</p>

<h1>

<script type="text/javascript">

/* Flip a Coin 1

Author: Michael Langerman. 2012

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program. If not, see <http://www.gnu.org/licenses/>.

*/

var randomNumber=(Math.floor(Math.random()*2)); //It generates random number 0 to 1;

display=(randomNumber=="0")?"Head":"Tail"; //if the var "display" is "0" it prints "Head", if "display" is "1" it prints "Tail"

document.write(display);

</script>

</h1>

</body>

</html>