Topic: Random Quote

Hey just thought I'd share a simple javascript to display a random quote.

I used it in my announcement box...

Jules

<script language="JavaScript">var Quotation=new Array();

// Set up the quotations to be shown, below.
// To add more quotations, continue with the
// pattern, adding to the array.  Remember
// to increment the Quotation[x] index!

Quotation[0] = "All yuor base are belong to us.";
Quotation[1] = "Getting intimate with digital photography.";
Quotation[2] = "Repent! The end is coming, $9.95 at Amazon.";
Quotation[3] = "I got kicked out of Riverdance for using my arms.";
Quotation[4] = "Pastry satisfies where art is unavailable.";
Quotation[5] = "Delete not, lest you, too, be deleted.";
Quotation[6] = "O! Youth! What a pain in the backside.";
Quotation[7] = "Wishes are like goldfish with propellors.";
Quotation[8] = "Digital photograpy news, views and reviews.";
Quotation[9] = "Invention is the mother of too many useless toys.";
Quotation[10] = "There are only two reasons to sit in the back row of an airplane: Either you have diarrhea, or you're anxious to meet people who do.";
Quotation[11] = "I filled out an application that said, 'In Case Of Emergency Notify'. I wrote 'Doctor'...What's my mother going to do?";
Quotation[12] = "I think animal testing is a terrible idea; they get all nervous and give the wrong answers.";
Quotation[13] = "If your parents never had children, chances are you won't either.";
Quotation[14] = "The difference between genius and stupidity is that genius has its limits.";
Quotation[15] = "Honesty is the best policy, but insanity is a better defense.";


// ======================================
// Do not change anything below this line
// ======================================
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>
Digital photography news, reviews, discussions and more!
http://www.shuttertalk.com

The online bible for all
http://www.publicbible.com

Re: Random Quote

Useful bit of code.

3 (edited by newera70 2004-06-18 17:35)

Re: Random Quote

I'd like to make a randomizing picture and i edited your code can you tell me if it will work I will giv you credit for the script... I just need to know if it works if it does i need to fix it so it willl have randomizing text to go with the picture...

<script language="JavaScript">var Picture=new Array();

// Set up the pictures to be shown, below.
// To add more pictures, continue with the
// pattern, adding to the array.  Remember
// to increment the Picture[x] index!

Picture[0] = "http://www.punkera.net/enter2.png";
Picture[1] = "http://www.punkera.net/enter2.png";
Picture[2] = "http://www.punkera.net/enter2.png";
Picture[3] = "http://www.punkera.net/enter2.png";
Picture[4] = "http://www.punkera.net/enter2.png";
Picture[5] = "http://www.punkera.net/enter2.png";
Picture[6] = "http://www.punkera.net/enter2.png";
Picture[7] = "http://www.punkera.net/enter2.png";
Picture[8] = "http://www.punkera.net/enter2.png";
Picture[9] = "http://www.punkera.net/enter2.png";
Picture[10] = "http://www.punkera.net/enter2.png";
Picture[11] = "http://www.punkera.net/enter2.png";
Picture[12] = "http://www.punkera.net/enter2.png";
Picture[13] = "http://www.punkera.net/enter2.png";
Picture[14] = "http://www.punkera.net/enter2.png";
Picture[15] = "http://www.punkera.net/enter2.png";


// ======================================
// Do not change anything below this line
// ======================================
var P = Picture.length;
var whichPicture=Math.round(Math.random()*(P-1));
function showPicture(){document.write(Picture[whichPicture]);}
showPicture();
</script>

http://www.punkera.net/enter2.png thats just a sample picture that is the enter to my site i used it just for example...

4

Re: Random Quote

Thanks guys smile I'd also like to know how Rickard does his random quote on the punBB index, if possible smile

5 (edited by newera70 2004-06-18 20:47)

Re: Random Quote

Andy just to let you know that the one I posted I don't even think its right I need help with it can you test it for me?

*EDIT* I tested it myself and it just outputs the www.punkera.net/enter2.png to the screen

6

Re: Random Quote

verry basic gd script.. i wrote it for random signature images a loong time ago, thats why its gd tongue..
the images has to be like
1.gif
2.gif
3.gif
if you want more than 3 just edit the total, and if you want another extension just change the file type var smile

<?php 
$total = "3";  
$file_type = ".gif";  
$start = "1";  
$random = mt_rand($start, $total);  
$image_name = $random . $file_type;  
 
Header("Content-Type: image/gif"); 
$fn = fopen("./$image_name","r"); 
fpassthru($fn); 
 
?> 

7 (edited by newera70 2004-06-19 02:03)

Re: Random Quote

i dont want it as php i want it as javascript or html

Re: Random Quote

where do i put this? i'm a n00b when it comes to most coding so help is appreciated.


cuteseal wrote:

Hey just thought I'd share a simple javascript to display a random quote.

I used it in my announcement box...

Jules

<script language="JavaScript">var Quotation=new Array();

// Set up the quotations to be shown, below.
// To add more quotations, continue with the
// pattern, adding to the array.  Remember
// to increment the Quotation[x] index!

Quotation[0] = "All yuor base are belong to us.";
Quotation[1] = "Getting intimate with digital photography.";
Quotation[2] = "Repent! The end is coming, $9.95 at Amazon.";
Quotation[3] = "I got kicked out of Riverdance for using my arms.";
Quotation[4] = "Pastry satisfies where art is unavailable.";
Quotation[5] = "Delete not, lest you, too, be deleted.";
Quotation[6] = "O! Youth! What a pain in the backside.";
Quotation[7] = "Wishes are like goldfish with propellors.";
Quotation[8] = "Digital photograpy news, views and reviews.";
Quotation[9] = "Invention is the mother of too many useless toys.";
Quotation[10] = "There are only two reasons to sit in the back row of an airplane: Either you have diarrhea, or you're anxious to meet people who do.";
Quotation[11] = "I filled out an application that said, 'In Case Of Emergency Notify'. I wrote 'Doctor'...What's my mother going to do?";
Quotation[12] = "I think animal testing is a terrible idea; they get all nervous and give the wrong answers.";
Quotation[13] = "If your parents never had children, chances are you won't either.";
Quotation[14] = "The difference between genius and stupidity is that genius has its limits.";
Quotation[15] = "Honesty is the best policy, but insanity is a better defense.";


// ======================================
// Do not change anything below this line
// ======================================
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>
~James
FluxBB - Less is more

Re: Random Quote

nevermind i figured it out. put it in the announcement box in the admin section. DUH! tongue

~James
FluxBB - Less is more

Re: Random Quote

Why do you need a random quote??? and if you have a site the put it into the HTML if your not sure howshow me your site and ill try and help......