Log in

View Full Version : Quote of the Day



queerfm
03-12-2008, 09:42 PM
Hi i would like to do a Quote of the day on my site and i wondered how?

Is there away i could fetch a random line from a txt file?

Nile
03-12-2008, 11:34 PM
Well, can you use js or php?

boogyman
03-13-2008, 01:53 PM
<script type="text/javascript">
var quoteArr = new Array();
quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");
quoteArr[] = new Array("__SOME_TEXT_OR_QUOTE__", "__CITATION__");

function getRandQuote()
{
// Citation - http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_shuffle/
for(var j, x, i = quoteArr.length; i; j = parseInt(Math.random() * i), x = quoteArr[--i], quoteArr[i] = quoteArr[j], quoteArr[j] = x);
return quoteArr[0];
}
</script>


place the above inside the <head></head> of the page you wish to use the quote on
place the below where you wish to view the quote on that page



<script type="text/javascript">
var today = getRandQuote();
document.write('<div><h2>Todays Quote:</h2>');
document.write('<p>'+today[0]+'<span style="display:block;text-align:right">'+today[1]+'</span></p></div>');
</script>