Random Text Generator

Posted on September 16, 2010


How to Make a Random Text Generator

As I promised Andrew Pickles (@efl101) this morning, here’s a quick post to explain how to make a simple random text generator. Click on the graphic below to see an example and get an idea of how it works. To randomize the text, click on the page Refresh icon of your browser. BTW, this example will form part of my next blog post on how students can keep on-line diaries.

Random Text Generator

It really wasn’t very difficult to create. First, I tweaked the original code (designed by Andy Angrick and Mike Barone and available at Javascript Source) to make the design a bit more attractive, then I added the 40 sentences that I wanted to appear in random order.

If you want to design your own, click here to get my tweaked code and here to get a colour-coded explanation (“The Code You Can Tweak” below) of which parts you should change to create your own generator. I suggest you copy and paste the code into Notepad (Start > programs > Accessories > Notepad) and make your changes there.

When you’ve finished, you must save it as an .html file (e.g. mygenerator.html), not a .txt file. Finally, open your generator in a browser (File > Open file) to check it works before making it available on the net. Oh, one thing I forgot to mention: you’re going to need server space! Very little, but you’re gonna have to hang it somewhere … hope you’ve got access to some! Good luck and have fun!

Code You Can Tweak

Hope you found this useful!

Posted in: App Lessons