Dice all editions

Dice 2 (click here to see the blogpost)

<html>

<body bgcolor=lightblue>

<center>

<form name=myForm>

<table border=3 cellpadding=1>

<td align=middle>

<input type=button value="Roll Dice" name=button onclick="roll()">

<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">

/* Dise 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 roll() { //function roll() runs everytime you click a button.

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

document.myForm.text.value = randomNumber;

}

//-->

</script>

</html>

<html>

<body>

<p>Rendom number from 1 to 6

<br>generates every time you open or refresh this page.

<br>Your dice shows:</p>

<h1>

<script type="text/javascript">

/* Dice 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/>.

The function Math.random () generates random numbers 0 to 1;

The function Math.floor()*6 generates six random numbers from 0 to 5;

We can use Increment ++ or +1 to change the numbers 1 to 6

*/

var randomNumber=(Math.floor(Math.random()*6)+1);

document.write(randomNumber);

</script>

</h1>

</body>

</html>