random quotes with javascript

Soldato
Joined
2 Jun 2004
Posts
18,423
i'm trying to add a javascript random quotes block to my site. it's working fine with the following code...

Code:
var quotes = new Array;

quotes.push("Thank you!");

quotes.push("&quot;Here is another quote.&quot;<br><br>John Doe<br>ACME Inc.");

quotes.push("Keep adding quotes like this.");

document.write(quotes[(Math.floor(Math.random() * quotes.length))]);

the problem is that it stops working when i change the second quote to the following...

Code:
quotes.push("&quot;"blah blah blah blah blah blah blah blah blah blah...blah blah blah blah...blah blah...blah blah blah...?"&quot;<br><br>John Doe<br>ACME Inc.");
how can i fix it so that it works with that quote?
 
looks like there is still a problem...

Code:
<script language="javascript" type="text/javascript">for (var i=0; i<quotes.length; document.write("<hr /><p>" + quotes[i++] + "</p>")) {};</script>
with this code i should be able to view all of my quotes on a single page. At the bottom of my random quotes block i want a "view all" link.

this works fine with the original quotes, but it doesn't work when i use hectors modification (above).

any ideas?
 
Last edited:
Back
Top Bottom