How do I put random quotes on my web site?

C

Chris Ianson

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.
 
J

Jim Moe

Chris said:
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.
 
C

Chris Ianson

Jim Moe said:
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!
 
M

Mitja Trampus

Chris said:
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.
 
C

Chris Ianson

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


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?
 
C

Chris Ianson

Jonathan N. Little said:
Chris Ianson wrote:


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.
 
T

Toby Inkster

Chris said:
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))));
?>
 
C

Chris Ianson

Toby Inkster said:
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)?
 
C

Chris Ianson

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.
 
J

Jonathan N. Little

Chris said:
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"
 
J

Jose

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
 
J

Jonathan N. Little

Jonathan N. Little wrote:

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>
 
J

Jim Higson

Chris said:
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.
 
N

Nick Theodorakis

Chris said:
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
 
N

Neredbojias

With neither quill nor qualm, Chris Ianson quothed:
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.
 
D

dorayme

Chris Ianson said:
Jonathan N. Little said:
Chris Ianson wrote:
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.

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?
 
D

dorayme

Chris Ianson said:
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?
 
C

Chris Ianson

Jose said:
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!)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top