Results 1 to 8 of 8

Thread: Random Text

  1. #1
    Join Date
    Nov 2004
    Little Britain

    Random Text

    Does anyone have a script for random text, which isn't remotely hosted?

  2. #2
    Join Date
    Jun 2004
    What langauge? This'd be easily achived in Javascript although I'd recomend you do it with PHP, ASP, asp.NET, JSP, Perl, CGI or whatever.

  3. #3
    Join Date
    Nov 2004
    Little Britain
    I can do it in anything, but would prefer javascript

  4. #4
    Join Date
    Jun 2004
    Anything?!?! Who are you hosted by? How did they manage that? I doubt this somehow.

    I'm not to familiar with JS, so I'll give you a PHP solution instead, I'm sure someone will come up with one for JS.
    PHP Code:
    [1] = "love";
    $text[2] = "hate";
    $text[3] = "have no opinoin regarding";

    $choice $text[ran(1,count($text))];
    <html lang="en">
    <title>My opinoin on PHP</title>
    <p>I must say, I <?=$choice ?> <abbr title="HyperText Preprosessor">PHP</abbr> don't you?</p>
    Last edited by the tree; 04-01-2005 at 10:14 AM.

  5. #5
    Join Date
    Jan 2005
    Most people don't check this, but if you search the JavaScript Forum with the keywords "random text" you'll find multiple ways to set up content arrays and have them display at random. Searching for your queries first can usually be a valuable and faster way to have them answered, especially if they are very general.

    Here is just one example of a result.

  6. #6
    Join Date
    Nov 2004
    Little Britain
    Thanks very much for your help!

  7. #7
    Join Date
    Mar 2005
    This is what I have used. It includes an author array but that can be taken out and changed. Hope this helps.

    <SCRIPT LANGUAGE="JavaScript">
    //store the quotations in arrays
    quotes = new Array(6);
    authors = new Array(6);
    quotes[0] = "The members of the Lone Star Scouts RV Club would like to thank you and your staff for the hospitality extended to us during our rally at your RV Park.”";
    authors[0] = "Tom Fausnacht - President Lone Star Scouts RV Club";
    quotes[1] = "Your facilities are picture postcard type.  Your RV Sites are clean, neat and level.  Your Hall couldn’t have been any better.  Thanks again for providing a great location for our rally.";
    authors[1] = "Herb and Gretta Lucas - Lone Star Bounder";
    quotes[2] = "Your new sign looks really great!!!!!  Man, you guys are really making this a great park!!!!  Hard work is paying off in eyeball appeal!!!";
    authors[2] = "Debbie Dominguez";
    quotes[3] = "Wonderful place to come.  Dorothy, Joe and all the staff are so polite and helpful.";
    authors[3] = "Jalanette and Harold Lewis";
    quotes[4] = "We love this place!  It was easy to find.  The bathrooms were really clean and the free movies were great.  They also have really good soda.";
    authors[4] = "Unknown Child";
    quotes[5] = "Eddie and I have really enjoyed our stay at the RV Ranch.  Your wonderful personality brightened some very difficult days.  Thank you for your support and encouragement...";
    authors[5] = "Eddie and Kathy";
    quotes[6] = "Dorothy is so kind and goes the extra mile to see that our needs have been met.  Joe is ready and willing no matter how cold it is...  You won’t be dissatisfied with your stay...";
    authors[6] = "Tony and Stacy Padgett";
    quotes[7] = "We always enjoy staying here at the RV Ranch.  The people are friendly and very helpful.  The surroundings are beautiful and kept spotless.";
    authors[7] = "Terry and Melissa Hann";
    quotes[8] = "We love you Dorothy more than you will ever know.  You are like family!!!  We’ll Be Backkkkkkkkkk!!";
    authors[8] = "Donna and Dean";
    //calculate a random index
    index = Math.floor(Math.random() * quotes.length);
    //display the quotation
    document.write("<DT><H6>" + "\" " + quotes[index] + "\"\n");
    document.write("<DD>" + "-- " + authors[index] + "\n");

  8. #8
    Join Date
    Jun 2003
    I've done an image in ASP, you can have the code if you want, all it does is redirect the users current page(or rather an image) to one based on the current day, I'm sure you could change it to use a random number.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles