www.webdeveloper.com
Results 1 to 8 of 8

Thread: Random Text

  1. #1
    Join Date
    Nov 2004
    Location
    Little Britain
    Posts
    352

    Random Text

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

  2. #2
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972
    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.
    Disclaimer. (1) Whilst I will help you sometimes, if I feel like it, and my advice in relation to your actual question will be of good quality: my posts are to be taken with a pinch of salt. I will be sarcastic, deploy irony and include obscure cultural references for my own amusement without warning.
    (2) You will gain nothing from complaining, and if you try to argue with me then you will not win. No matter how noble your battle seems, I am still better than you, don't be an hero.

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

  4. #4
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972
    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:
    <?php
    $text
    [1] = "love";
    $text[2] = "hate";
    $text[3] = "have no opinoin regarding";

    $choice $text[ran(1,count($text))];
    ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>My opinoin on PHP</title>
    </head>
    <body>
    <p>I must say, I <?=$choice ?> <abbr title="HyperText Preprosessor">PHP</abbr> don't you?</p>
    </body>
    </html>
    Last edited by the tree; 04-01-2005 at 10:14 AM.
    Disclaimer. (1) Whilst I will help you sometimes, if I feel like it, and my advice in relation to your actual question will be of good quality: my posts are to be taken with a pinch of salt. I will be sarcastic, deploy irony and include obscure cultural references for my own amusement without warning.
    (2) You will gain nothing from complaining, and if you try to argue with me then you will not win. No matter how noble your battle seems, I am still better than you, don't be an hero.

  5. #5
    Join Date
    Jan 2005
    Location
    California
    Posts
    135
    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.
    Faster than an OC-48 Line! More powerful than an AMD Athlon 64 FX-55 Processor! Able to jump entire forums in a single bound!

    Roses are #FF0000, violets are #0000FF...

    Feeling the angst of a teenage torpor? Visit A to the Power of Two for help/hinderance.

    "...and the Lord said to John, Come forth and ye shall receive eternal life, but instead John came fifth and won a toaster."

    <pihlopase> Jesus Saves
    <jbroome> pases to moses, SCOOOOORE

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

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

    Code:
    <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("<DL>\n");
    document.write("<DT><H6>" + "\" " + quotes[index] + "\"\n");
    document.write("<DD>" + "-- " + authors[index] + "\n");
    document.write("</DL>\n");
    
    //done
    </SCRIPT>

  8. #8
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    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.
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

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