How do I put random quotes on my web site?

Discussion in 'HTML' started by Chris Ianson, Mar 10, 2006.

  1. Chris Ianson

    Chris Ianson Guest

    Hi, I'm looking for a simple newbie way to put quotes into HTML code, and
    have them randomise each time the page is refreshed. What's the easy
    solution?

    Thanks in advance.
     
    Chris Ianson, Mar 10, 2006
    #1
    1. Advertising

  2. Chris Ianson

    Jim Moe Guest

    Chris Ianson wrote:
    > Hi, I'm looking for a simple newbie way to put quotes into HTML code, and
    > have them randomise each time the page is refreshed. What's the easy
    > solution?
    >

    Client-side: use Javascript. Server-side: use PHP, JSP, perl, etc.
    Open a file of quotes, use a random number generator to select a line of
    text, print it.

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
     
    Jim Moe, Mar 10, 2006
    #2
    1. Advertising

  3. Chris Ianson

    Chris Ianson Guest

    "Jim Moe" <> wrote in message
    news:...
    > Chris Ianson wrote:
    >> Hi, I'm looking for a simple newbie way to put quotes into HTML code, and
    >> have them randomise each time the page is refreshed. What's the easy
    >> solution?
    >>

    > Client-side: use Javascript. Server-side: use PHP, JSP, perl, etc.
    > Open a file of quotes, use a random number generator to select a line of
    > text, print it.


    Sorry, can you show me an example in Java please, with say 2 quotes. I have
    no idea what any of that means :S

    Thanks!

    >
    > --
    > jmm (hyphen) list (at) sohnen-moe (dot) com
    > (Remove .AXSPAMGN for email)
     
    Chris Ianson, Mar 10, 2006
    #3
  4. Chris Ianson wrote:
    > "Jim Moe" <> wrote in message
    > news:...
    >> Chris Ianson wrote:
    >>> Hi, I'm looking for a simple newbie way to put quotes into HTML code, and
    >>> have them randomise each time the page is refreshed. What's the easy
    >>> solution?
    >>>

    >> Client-side: use Javascript. Server-side: use PHP, JSP, perl, etc.
    >> Open a file of quotes, use a random number generator to select a line of
    >> text, print it.

    >
    > Sorry, can you show me an example in Java please, with say 2 quotes.


    Java and JavaScript are two entirely different things. Java is in fact hidden in the "JSP"
    above - Java Server Pages.

    > I have
    > no idea what any of that means :S


    Then no example can help you (enough). The easiest (though shoddiest) way to go is
    JavaScript; you can find a script on Google with instruction on how to put it on your
    site, requiring no knowledge of what is actually going on.
     
    Mitja Trampus, Mar 10, 2006
    #4
  5. Chris Ianson

    Chris Ianson Guest

    "Mitja Trampus" <> wrote in message
    news:aTnQf.794$...
    > Chris Ianson wrote:
    >> "Jim Moe" <> wrote in message
    >> news:...
    >>> Chris Ianson wrote:
    >>>> Hi, I'm looking for a simple newbie way to put quotes into HTML code,
    >>>> and
    >>>> have them randomise each time the page is refreshed. What's the easy
    >>>> solution?
    >>>>
    >>> Client-side: use Javascript. Server-side: use PHP, JSP, perl, etc.
    >>> Open a file of quotes, use a random number generator to select a line
    >>> of
    >>> text, print it.

    >>
    >> Sorry, can you show me an example in Java please, with say 2 quotes.

    >
    > Java and JavaScript are two entirely different things. Java is in fact
    > hidden in the "JSP" above - Java Server Pages.
    >
    > > I have
    >> no idea what any of that means :S

    >
    > Then no example can help you (enough). The easiest (though shoddiest) way
    > to go is JavaScript; you can find a script on Google with instruction on
    > how to put it on your site, requiring no knowledge of what is actually
    > going on.


    Yes, I have found some JaveScripts, but even though I copy and paste them
    exactly I still get script errors in IE6.

    Perhaps someone can post a working example here with 2 quotes?
     
    Chris Ianson, Mar 11, 2006
    #5
  6. Jonathan N. Little, Mar 11, 2006
    #6
  7. Chris Ianson

    Chris Ianson Guest

    "Jonathan N. Little" <> wrote in message
    news:44122921$0$25074$...
    > Chris Ianson wrote:
    > <snip>
    >>
    >> Yes, I have found some JaveScripts, but even though I copy and paste them
    >> exactly I still get script errors in IE6.
    >>
    >> Perhaps someone can post a working example here with 2 quotes?

    >
    > help yourself!
    >
    >
    > http://www.google.com/search?hl=en&lr=&q=javascript random quote of the day&btnG=Search
    > javascript random quote of the day - Google Search


    All very well but these are mainly links to other people's quotes (I want my
    own). Then there are scripts which are either dead links, or PHP (I need
    JavaScript), or just plain don't work.

    Is anybody here able to paste a small bit of HTML to a reply that will
    enable me to add my own random text to be displayed on each screen refresh?

    Thanks if you can.

    > --
    > Take care,
    >
    > Jonathan
    > -------------------
    > LITTLE WORKS STUDIO
    > http://www.LittleWorksStudio.com
     
    Chris Ianson, Mar 11, 2006
    #7
  8. Chris Ianson

    Toby Inkster Guest

    Chris Ianson wrote:

    > Hi, I'm looking for a simple newbie way to put quotes into HTML code, and
    > have them randomise each time the page is refreshed. What's the easy
    > solution?


    If your server supports PHP...

    <?php
    $cmd = '/usr/games/fortune';
    printf("<blockquote><p>%s</p></blockquote>",
    nl2br(htmlspecialchars(system($cmd))));
    ?>

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Mar 11, 2006
    #8
  9. Chris Ianson

    Chris Ianson Guest

    "Toby Inkster" <> wrote in message
    news:5n.co.uk...
    > Chris Ianson wrote:
    >
    >> Hi, I'm looking for a simple newbie way to put quotes into HTML code, and
    >> have them randomise each time the page is refreshed. What's the easy
    >> solution?

    >
    > If your server supports PHP...
    >
    > <?php
    > $cmd = '/usr/games/fortune';
    > printf("<blockquote><p>%s</p></blockquote>",
    > nl2br(htmlspecialchars(system($cmd))));
    > ?>


    Thanks. What if it doesn't support PHP (it doesn't)?

    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me ~ http://tobyinkster.co.uk/contact
    >
     
    Chris Ianson, Mar 11, 2006
    #9
  10. Chris Ianson

    Chris Ianson Guest

    PS: I would also like it to not only display a random phrase on first page
    load, but to also display a random one every 15 seconds.
     
    Chris Ianson, Mar 11, 2006
    #10
  11. Chris Ianson wrote:
    > "Jonathan N. Little" <> wrote in message
    > news:44122921$0$25074$...
    >
    >>Chris Ianson wrote:
    >><snip>
    >>
    >>>Yes, I have found some JaveScripts, but even though I copy and paste them
    >>>exactly I still get script errors in IE6.
    >>>
    >>>Perhaps someone can post a working example here with 2 quotes?

    >>
    >>help yourself!
    >>
    >>
    >>http://www.google.com/search?hl=en&lr=&q=javascript random quote of the day&btnG=Search
    >>javascript random quote of the day - Google Search

    >
    >
    > All very well but these are mainly links to other people's quotes (I want my
    > own). Then there are scripts which are either dead links, or PHP (I need
    > JavaScript), or just plain don't work.


    Don't know what's up with #3 link irt.org, they been around forever, but
    #4 would do! Hotscripts has many examples that could be adaptable like:

    http://www.hotscripts.com/Detailed/48180.html
    Quote Randomizer

    Took no effort. It is a very easy concept to code, a little research and
    you might learn something. You know the old saying..."Give a man a fish
    and he is fed for a day, teach a man to fish and he will never be hungry"

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Mar 11, 2006
    #11
  12. Chris Ianson

    Jose Guest

    > PS: I would also like it to not only display a random phrase on first page
    > load, but to also display a random one every 15 seconds.


    I do not like pages to reload and re-contact the internet every fifteen
    seconds, especially for something as trivial as that. It would annoy me
    to no end and I would likely not return.

    Jose
    --
    Money: what you need when you run out of brains.
    for Email, make the obvious change in the address.
     
    Jose, Mar 11, 2006
    #12
  13. Jonathan N. Little wrote:

    <snip>
    > Don't know what's up with #3 link irt.org, they been around forever, but


    Well going to www.irt.org works and there are beaucoup scripts and
    tutorials, so help yourself!

    To get you started look at:

    http://www.irt.org/script/116.htm
    Q116 Is it possible to display a random bit of text at the bottom of a
    web page ("quote of the day") that changes either on each visit or each day?

    <snip>

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Mar 11, 2006
    #13
  14. Chris Ianson

    Jim Higson Guest

    Chris Ianson wrote:

    > "Toby Inkster" <> wrote in message
    > news:5n.co.uk...
    >> Chris Ianson wrote:
    >>
    >>> Hi, I'm looking for a simple newbie way to put quotes into HTML code,
    >>> and
    >>> have them randomise each time the page is refreshed. What's the easy
    >>> solution?

    >>
    >> If your server supports PHP...
    >>
    >> <?php
    >> $cmd = '/usr/games/fortune';
    >> printf("<blockquote><p>%s</p></blockquote>",
    >> nl2br(htmlspecialchars(system($cmd))));
    >> ?>

    >
    > Thanks. What if it doesn't support PHP (it doesn't)?


    Does it support any scripting language?

    There's a unix program called 'fortune' that's installed on pretty much all
    servers and is just for getting quotes. A neat solution would be to put the
    output from that into your pages.

    --
    Jim
     
    Jim Higson, Mar 11, 2006
    #14
  15. Chris Ianson wrote:
    > Hi, I'm looking for a simple newbie way to put quotes into HTML code, and
    > have them randomise each time the page is refreshed. What's the easy
    > solution?
    >
    > Thanks in advance.
    >
    >


    You can't do this only with html; you need some kind of scripting
    language. There is a premade script for this on the nms website:

    <http://nms-cgi.sourceforge.net/>

    Their scripts can be found here:

    <http://nms-cgi.sourceforge.net/scripts.shtml>

    The one you want is called "Random Text"

    You need cgi/perl on your host (and ssi enabled), and know how to change
    permissions on your cgi file.

    An example of this script in action can be found here:

    <http://www.stjohnsroch.org/randomquote.html>

    Nick

    --
    Nick Theodorakis

    contact form:
    http://theodorakis.net/contact.html
     
    Nick Theodorakis, Mar 11, 2006
    #15
  16. Chris Ianson

    Neredbojias Guest

    With neither quill nor qualm, Chris Ianson quothed:

    > "Jonathan N. Little" <> wrote in message
    > news:44122921$0$25074$...
    > > Chris Ianson wrote:
    > > <snip>
    > >>
    > >> Yes, I have found some JaveScripts, but even though I copy and paste them
    > >> exactly I still get script errors in IE6.
    > >>
    > >> Perhaps someone can post a working example here with 2 quotes?

    > >
    > > help yourself!
    > >
    > >
    > > http://www.google.com/search?hl=en&lr=&q=javascript random quote of the day&btnG=Search
    > > javascript random quote of the day - Google Search

    >
    > All very well but these are mainly links to other people's quotes (I want my
    > own). Then there are scripts which are either dead links, or PHP (I need
    > JavaScript), or just plain don't work.
    >
    > Is anybody here able to paste a small bit of HTML to a reply that will
    > enable me to add my own random text to be displayed on each screen refresh?


    Uh, it's a bit more than a "small bit" of _scripting_ and html.
    However, if you want a custom-made "quot-o-gram", I'll do it for 100
    dollars US.

    > Thanks if you can.


    No problem.

    --
    Neredbojias
    Contrary to popular belief, it is believable.
     
    Neredbojias, Mar 11, 2006
    #16
  17. Chris Ianson

    dorayme Guest

    In article <1lxQf.34058$>,
    "Chris Ianson" <> wrote:

    > "Jonathan N. Little" <> wrote in message
    > news:44122921$0$25074$...
    > > Chris Ianson wrote:
    > > <snip>
    > >>
    > >> Yes, I have found some JaveScripts, but even though I copy and paste them
    > >> exactly I still get script errors in IE6.
    > >>
    > >> Perhaps someone can post a working example here with 2 quotes?


    snip
    >
    > Is anybody here able to paste a small bit of HTML to a reply that will
    > enable me to add my own random text to be displayed on each screen refresh?
    >
    > Thanks if you can.
    >
    > > --
    > > Take care,
    > >
    > > Jonathan


    I wrote a random pic thing a while ago that worked, surely it can
    be easily adapted for just text... if I have to I will take
    another look, but I am sure you can see a way to proceed
    Jonathan...

    http://dorayme.150m.com/randomPics/ranpicTrial.html

    or have I picked up a fag end here?

    --
    dorayme
     
    dorayme, Mar 11, 2006
    #17
  18. Chris Ianson

    dorayme Guest

    In article <j7yQf.34070$>,
    "Chris Ianson" <> wrote:

    > PS: I would also like it to not only display a random phrase on first page
    > load, but to also display a random one every 15 seconds.


    Oh well, hang on... you never said anything about this! The simpl
    script I posted just before is to randomly change pics (text) on
    every refresh or fresh load...

    Every 15 sec eh? Why on earth... who can read things in under 15
    sec, call someone over to look at a terrific quote, wait for a
    crowd to gather, open a few tinnies and have a laugh or wondering
    gaze in 15 secs?

    --
    dorayme
     
    dorayme, Mar 11, 2006
    #18
  19. Chris Ianson

    dorayme Guest

    In article <1lxQf.34058$>,
    "Chris Ianson" <> wrote:

    > "Jonathan N. Little" <> wrote in message
    > news:44122921$0$25074$...


    >
    > Is anybody here able to paste a small bit of HTML to a reply that will
    > enable me to add my own random text to be displayed on each screen refresh?
    >
    > Thanks if you can.
    >
    > > --
    > > Take care,
    > >
    > > Jonathan


    Sorry, misread this as from JNL. Anyway, OP can see...

    --
    dorayme
     
    dorayme, Mar 11, 2006
    #19
  20. Chris Ianson

    Chris Ianson Guest

    "Jose" <> wrote in message
    news:0iBQf.19644$...
    >> PS: I would also like it to not only display a random phrase on first
    >> page load, but to also display a random one every 15 seconds.

    >
    > I do not like pages to reload and re-contact the internet every fifteen
    > seconds, especially for something as trivial as that. It would annoy me
    > to no end and I would likely not return.


    I don't recall saying I wanted the page to reload. I only want the quote to
    change every xx seconds (it might not be 15!)

    > Jose
    > --
    > Money: what you need when you run out of brains.
    > for Email, make the obvious change in the address.
     
    Chris Ianson, Mar 13, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,913
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,757
    Oisin
    Mar 24, 2006
  3. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,548
    Andrew Thompson
    Dec 24, 2003
  4. globalrev
    Replies:
    4
    Views:
    817
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,325
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page