JavaScript Random Array Display

 

This script will display a random quote form an array within JavaScript. Every time the page loads or has a refresh, a different quote will be displayed.

Try it!

 

 

Example



 

Script Source

<script type="text/javascript">
<!-- Begin
Random = new Array
Random[1]="This is random quote number 1"
Random[2]="This is random quote number 2"
Random[3]="This is random quote number 3"
Random[4]="This is random quote number 4"
Random[5]="This is random quote number 5"

random_num = (Math.round((Math.random()*4)+1))

document.write(Random[random_num]);
//--> End
</script>

 

Please let me know if this script was helpful to you.

[rating]