View Full Version : How to random content?

12-01-2009, 10:11 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-01-2009, 10:27 AM

Easily display a random piece of content chosen from many on the page to your visitors using this script! Just wrap the participating contents each inside a DIV with a special CSS classname, and that's it! Furthermore, you can have multiple "groups" of random content, with the script picking one to display randomly for each group.

This script comes with accessibility in mind- browsers with JavaScript disabled will simply see all the contents at once.

12-02-2009, 05:12 AM
Thank you for the idea mdsraj. But I don't want to populate my page with hidden div's (if that's what you're suggesting) and displaying one div randomly. I want it to be retrieved from a text file so that when new quote or entry is available, I will just append it to the end of the text file and then save it. With div's, it will take a lot or at least more coding than with text file.

Is that possible? Please show the script. Thanks

12-02-2009, 06:29 AM
well ur looking for sum javascript to do a job for u and this is the html/css category so u most likely will not find much luck here u really should post this in the javascript section