Advanced Search

Results 1 to 3 of 3

Thread: Quote of the Day

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Quote of the Day

    Hi i would like to do a Quote of the day on my site and i wondered how?

    Is there away i could fetch a random line from a txt file?
    The web in one word.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,158
    Thanks
    28
    Thanked 623 Times in 619 Posts
    Blog Entries
    1

    Default

    Well, can you use js or php?
    Jeremy | jfein.net

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Code:
    <script type="text/javascript">
    var quoteArr = new Array();
    quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
    quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
    quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
    quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
    quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
    
    function getRandQuote()
    {
         // Citation - http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_shuffle/
         for(var j, x, i = quoteArr.length; i; j = parseInt(Math.random() * i), x = quoteArr[--i], quoteArr[i] = quoteArr[j], quoteArr[j] = x);
         return quoteArr[0];
    }
    </script>
    place the above inside the <head></head> of the page you wish to use the quote on
    place the below where you wish to view the quote on that page

    Code:
    <script type="text/javascript">
    var today = getRandQuote();
    document.write('<div><h2>Todays Quote:</h2>');
    document.write('<p>'+today[0]+'<span style="display:block;text-align:right">'+today[1]+'</span></p></div>');
    </script>

Bookmarks

Posting Permissions

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