|
Helping ordinary people create extraordinary websites! |
How to Setup a Randomising FunctionBy Arbitrary Constant2007-11-17
Defining your entities In this case, we wish to generate a random quote, so we need to define a long list of quotes from which a script can pick one out. To do this, we define an array. An array
is basically a one-dimensional matrix that contains every possible
piece of information in it you would like displayed. It is from the array that the randomising function will pick the random (in this case) quote.
The script utilised in the example in the right column uses the following
array:
quotes = new Array
It is that simple. Of course, there are many ways to create an array,
but in this case, this was the easiest way of finding a solution to the
given requirements. The only thing to note is that the
array
is named "quotes" and that the last quote does not have a comma before
the close parenthesis. If it did have a comma, the script wouldn't
work.
Tutorial Pages: » How to set up a randomising function » Defining your entities » Defining a randomising function » Displaying the random entity |
|