View Full Version : random text?
12-02-2009, 10:38 AM
I have a text file(quotes.txt) with 35+ quotations, separated by a single line break. Is it possible for a DIV to display a random quotation from quotes.txt each time the user visit my home page?
12-02-2009, 10:44 AM
12-02-2009, 11:43 AM
<span id = "quote"></span>
var Quotation = new Array();
Quotation = "Time is of the essence! Comb your hair.";
Quotation = "Sanity is a golden apple with no shoelaces.";
Quotation = "Repent! The end is coming, $9.95 at Amazon.";
Quotation = "Honesty blurts where deception sneezes.";
Quotation = "Pastry satisfies where art is unavailable.";
Quotation = "Delete not, lest you, too, be deleted.";
Quotation = "O! Youth! What a pain in the backside.";
Quotation = "Wishes are like goldfish with propellors.";
Quotation = "Love the river's \"beauty\", but live on a hill."; // note escape quotes
Quotation = "Invention is the mother of too many useless toys.";
var Q = Quotation.length;
var whichQuotation = Math.round(Math.random()*(Q-1));
document.getElementById("quote").innerHTML = Quotation[whichQuotation];
"By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.