View Single Post
Old 03-21-2009, 03:53 AM   #2 (permalink)
runningbird
Senior Member
 
Join Date: Oct 2008
Location: Cleveland, OH
Posts: 614
runningbird is on a distinguished road
Default

I can tell you how to do it in javascript - very easy.

Start by declaring an array; each quote will be one element in the array. So you have:

var quotes = new Array(11);
quote[0] = "You are what you eat";
quote[1] = "Government is a lousy master and a treacherous servant";
quote[2] = "For the first time in history, it is possible to meet the needs for 100% of the global population";
etc.

So if you have 11 quotes your last one will be quote[10];

Then, to choose a random number of the array make a random number generator:

var choice = Math.floor(Math.random()*11);

Math.floor is to get an integer number. ^That 11 is because I assume 11 quotes; adjust it to your number. (Math.random() gives you a random decimal between 0 and 1)

Then just write it.

document.write(quotes[choice]);

Write that in text editor and save as something like quote_gen.js

Then upload the file onto your sever. Where you want it to appear, insert the script:

<script src="quote_gen.js" type="text/javascript"></script>
runningbird is offline   Reply With Quote