How to write a random phrase to the screen
Source for random.html

<HTML>
<HEAD>
<TITLE>Random Jokes</TITLE>
<SCRIPT LANGUAGE="Javascript">
<!--
/* 	code by Wyatt Houtz 
	whoutz@oakland.edu
	http://www.oakland.edu/~whoutz/
*/

var njoke = 20;  // number of jokes

var jokes = new Array(njoke);
jokes[0] = 'joke number 1';
jokes[1] = 'joke number 2';
jokes[2] = 'joke number 3';
jokes[3] = 'joke number 4';
jokes[4] = 'joke number 5';
jokes[5] = 'joke number 6';
jokes[6] = 'joke number 7';
jokes[7] = 'joke number 8';
jokes[8] = 'joke number 9';
jokes[9] = 'joke number 10';
jokes[10] = 'joke number 11';
jokes[11] = 'joke number 12';
jokes[12] = 'joke number 13';
jokes[13] = 'joke number 14';
jokes[14] = 'joke number 15';
jokes[15] = 'joke number 16';
jokes[16] = 'joke number 17';
jokes[17] = 'joke number 18';
jokes[18] = 'joke number 19';
jokes[19] = 'joke number 20';
// You may add or subtract jokes at will

var ranNum = njoke;

while (ranNum >= njoke) {
	ranNum = Math.random();
	ranNum *= 100;
	ranNum = roundme(ranNum);
	}

function roundme(x) {
	return Math.round(x);
	}
// -->
</script>
</head>
<body>



<script lanuage=Javascript>
<!-- This writes the joke in the document.
document.write(jokes[ranNum]);  
// -->
</SCRIPT>

</body>
</html>
Back