Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > How do I put random quotes on my web site?

Reply
Thread Tools

How do I put random quotes on my web site?

 
 
Chris Ianson
Guest
Posts: n/a
 
      03-13-2006
Thanks Jonathan for a helpful reply.

"Jonathan N. Little" <> wrote in message
news:4412d9a3$0$25071$. ..
> 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&l...ay&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



 
Reply With Quote
 
 
 
 
Jose
Guest
Posts: n/a
 
      03-13-2006
> 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!)


Some browsers will reload the page. With HTML that's the only way to do
it (that I know of). And it's still a distraction for something
frivolous. I would not impose this on my viewers.

Jose
--
Money: what you need when you run out of brains.
for Email, make the obvious change in the address.
 
Reply With Quote
 
 
 
 
Toby Inkster
Guest
Posts: n/a
 
      03-13-2006
Jose wrote:

> Some browsers will reload the page. With HTML that's the only way to do
> it (that I know of).


Then you don't know of very much:

<p>
<b>No reloads:</b>
<input id="foo" style="width:100%">
</p>
<script type="text/javascript">
quote = new Array(4);
quote[0] = "I came, I saw, I conquered";
quote[1] = "Men believe that willingly which they wish to be true.";
quote[2] = "All bad precedents begin as justifiable measures.";
quote[3] = "Et tu, Brute.";
function randquote ()
{
var f = document.getElementById("foo");
var q = Math.round(Math.random()*4);
f.value = quote[q];
setTimeout("randquote();", 15000);
}
randquote();
</script>

Ideally, you probably don't want an <INPUT> element, but want to use <Q>
or such. Done easily enough though.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Jose
Guest
Posts: n/a
 
      03-14-2006
> Then you don't know of very much: [followed by a javascript example]

I said with HTML.... Is Javascript HTML?

(maybe yes... I don't know, but I'm a purist)

Jose
--
Money: what you need when you run out of brains.
for Email, make the obvious change in the address.
 
Reply With Quote
 
Chris Ianson
Guest
Posts: n/a
 
      03-17-2006
"Toby Inkster" <> wrote in message
news:l3rge3-...

<snip>

> setTimeout("randquote();", 15000);
> }
> randquote();
> </script>
>
> Ideally, you probably don't want an <INPUT> element, but want to use <Q>
> or such. Done easily enough though.
>
> --
> Toby A Inkster BSc (Hons) ARCS
> Contact Me ~ http://tobyinkster.co.uk/contact


That's great Toby. Here's the actual code I found that worked for the page
refresh, but didn't include your timeout.

Can you help me integrate a timeout function into my existing code below, so
the quote changes say every 45 seconds, and is also randomised on page
refresh please?

<script language="JavaScript">
var howMany = 2
var quote = new Array(howMany+1)
quote[0]="quote1"
quote[1]="quote2"
quote[2]="quote3"
function rndnumber(){
var randscript = -1
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1))
}
return randscript
}
quo = rndnumber()
quox = quote[quo]
document.write(quox)
// End --></script>

Thanks in advance


 
Reply With Quote
 
Chris Ianson
Guest
Posts: n/a
 
      03-21-2006
"Chris Ianson" <> wrote in message
news:X7HSf.37639$. uk...
>> setTimeout("randquote();", 15000);
>> }
>> randquote();
>> </script>
>>
>> Ideally, you probably don't want an <INPUT> element, but want to use <Q>
>> or such. Done easily enough though.
>>
>> --
>> Toby A Inkster BSc (Hons) ARCS
>> Contact Me ~ http://tobyinkster.co.uk/contact

>
> That's great Toby. Here's the actual code I found that worked for the
> page refresh, but didn't include your timeout.
>
> Can you help me integrate a timeout function into my existing code below,
> so the quote changes say every 45 seconds, and is also randomised on page
> refresh please?
>
> <script language="JavaScript">
> var howMany = 2
> var quote = new Array(howMany+1)
> quote[0]="quote1"
> quote[1]="quote2"
> quote[2]="quote3"
> function rndnumber(){
> var randscript = -1
> while (randscript < 0 || randscript > howMany || isNaN(randscript)){
> randscript = parseInt(Math.random()*(howMany+1))
> }
> return randscript
> }
> quo = rndnumber()
> quox = quote[quo]
> document.write(quox)
> // End --></script>
>
> Thanks in advance


Any ideas Tony or anyone?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Asp.NET Javascript string, want to pass '(single quotes' within '(single quotes) Chris ASP .Net 1 03-24-2006 09:03 PM
Quotes/Double Quotes in Image Control Chris White ASP .Net 1 09-22-2004 06:22 AM
Multiline quotes - escaping quotes - et al Lawrence Tierney Java 3 12-24-2003 05:12 PM



Advertisments