I need a daily quoter in my website (new quote everyday). I need it to be put as text in the sidebar. The "Tip of the day" script in main dynamic drive pages loads in a pop-up before the site loads. I don't like it that way actually.
Any ideas?
I need a daily quoter in my website (new quote everyday). I need it to be put as text in the sidebar. The "Tip of the day" script in main dynamic drive pages loads in a pop-up before the site loads. I don't like it that way actually.
Any ideas?
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Thanks John, but..
I noticed I have to assign 31 htms beforehand. Not that this is annoying, but I'd like to put like 200 quotes to choose randomly from; In a single txt file for instance. Can that be done?
html and javascript have no server access. you'd have to use serverside scripting, like php to do this. You could use a database or a text file. You might be able to use javascript, but it would be client side, and slow down the users computer.
I think so, you could make like an external or internal javascript. Your quotes could be in an array. A random quote could be selected from the array on each page load and be assigned as the innerHTML of a division.Originally Posted by Haisook
Only thing is it would be random on each page load, not a daily quote, or you could have it based on the day of the year, each day would bring the next quote, in order until the end was reached, then it could start over.
I just had a had a bunch of paid work dumped in my lap but, I think I will write this idea up at some point. Shouldn't really take all that long. If I had the list of 200 quotes to work from, that would make things easier to visualize.
Also would you be most interested in a random or a daily progression?
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
OK, here's a first effort. No quotes in the quotes unless escaped -
he said,\"Hello\".
The script is pretty easy to follow:
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <title>Random or Daily Quotes - Demo</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> #quote { /*style for quote division*/ position:relative; width:375px; height:70px; border:1px solid black; font-family:sans-serif; font-size:95%; padding:3px; background-color:lightyellow; } #auth { /*style for quote author, if any*/ position:absolute; bottom:3px; right:10px; } </style> <script type="text/javascript"> /*/////////////////////////////// * Random or Daily Quotes Script © John Davenport Scheuer * as first seen in http://www.dynamicdrive.com/forums * user name jscheuer1 - This credit must remain for * legal use. Ver Date: 4/1/2006 ///////////////////////////////*/ var method=0 //Set to 1 for rotating daily, 0 for random each page load ////////////BEGIN QUOTES: (Start Editing after next line)////////// var quotes="\ Sed ut perspiciatis unde omnis iste natus error sit voluptatem.~Plato^\ Accusantium doloremque laudantium totam rem aperiam.^\ Eaque ipsa quae ab illo inventore veritatis et quasi architecto.~Plato^\ Beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia.^\ Voluptas sit aspernatur aut odit aut fugit.~Plato^\ Sed quia consequuntur magni dolores eos qui ratione.^\ Voluptatem sequi nesciunt. Neque porro quisquam est.~Plato^\ Qui dolorem ipsum quia dolor sit amet.^\ Illegitimi Non Carborundum.~General 'Vinegar Joe' Stilwell^\ Consectetur, adipisci velit sed quia non numquam eius modi.~Plato^\ Tempora incidunt ut labore et dolore magnam aliquam quaerat.^\ Voluptatem. Ut enim ad minima veniam.~Plato^\ Quis nostrum exercitationem ullam corporis suscipit laboriosam.^\ Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum.~Plato^\ Iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur.^\ Vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?~Socrates^\ " ///////////END QUOTES (Stop Editing)//////////// quotes=quotes.split("^") quotes.length=quotes.length-1 if(method){ var qdate=new Date() var qnum=Math.ceil((qdate.valueOf()-new Date(qdate.setMonth(0)).setDate(1))/(1000*60*60*24))%(quotes.length-1) } else var qnum=Math.floor(quotes.length*Math.random()) </script> </head> <body> <!-- Begin Body Section of Quote Script --> <noscript><div id="quote">"Quis nostrum exercitationem ullam corporis suscipit laboriosam."<span id="auth"> ~ Plato</span></div></noscript> <script type="text/javascript"> document.write('<div id="quote"></div>') var quotediv=document.getElementById?document.getElementById('quote'):documet.all['quote'] quotediv.innerHTML=/~/.test(quotes[qnum])? '"'+quotes[qnum].replace(/~/, '"<span id="auth"> ~ ')+' </span>' : '"'+quotes[qnum]+'"' </script> <!-- End Body Section of Quote Script --> </body> </html>
Last edited by jscheuer1; 04-02-2006 at 09:30 AM. Reason: Handle DST gracefully
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Thanks djr33 for your reply.
John,
Oh.. your script is great! Thank you for your effort. This should be sumbitted to dynamicdrive's database I must say.
I noticed it shows a new random quote on each pageload. Still a cool effect for certain needs, but I wonder if you could make it in a daily progression..?! I just want to avoid having all the quotes read in one day!
Thanks again
Sorry I have just seen the option for daily quotes.
Thanks a lot!
And just this morning it stopped working! I've edited the code so that it can handle DST gracefully. If you just want to edit the line involved:Originally Posted by Haisook
Don't miss the lonely ) nearer to the end of the line.Code:var qnum=Math.ceil((qdate.valueOf()-new Date(qdate.setMonth(0)).setDate(1))/(1000*60*60*24))%(quotes.length-1)
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Ok, i'll edit it.. thanks, though it worked for 2 days until now without any problems.
Bookmarks