...

View Full Version : Random Text box (fpr 24 hours per text)



Aishah
08-31-2007, 04:59 PM
Hi,

A friend has been asking about some sort of a script that can be used on websites.

What they have are a list of quotes, from different people, and what theyw ould like to do is have a box on their website, say, the home page, and then every 24 hours, the quote changes, instead of simply having a 'random quote box' which displays randomly every time you refresh the page.

They want it so visitors may take the code and place it on their own websites and blogs if they want to.

Thanks.

lithriel
09-01-2007, 07:00 AM
You might want to ask the javascript people. This isn't an xhtml/css question. =)

The Javascript Source might have something like that though if you are up for browsing: http://javascript.internet.com/

Aishah
09-02-2007, 01:16 AM
Thanks, I'll have a look.

coothead
09-02-2007, 09:57 AM
Hi there Aishah,

this simple script will display a different quote for every day of the year....

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>364/365 quotes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
#quote {
width:740px;
padding:10px;
border:3px double #999;
text-align:center;
margin:20px auto;
}
</style>

<script type="text/javascript">
var quotes=new Array();
quotes[0]='quote one'; //first quote of the year
quotes[1]='quote two';
quotes[2]='quote three';

quotes[244]='quote two hundred and forty five';
quotes[245]='quote two hundred and forty six';
quotes[246]='quote two hundred and forty seven';
quotes[247]='quote two hundred and forty eight';
quotes[248]='quote two hundred and forty nine';
quotes[249]='quote two hundred and fifty';
quotes[250]='quote two hundred and fifty one';
quotes[251]='quote two hundred and fifty two';

quotes[363]='quote three hundred and sixty four';
quotes[364]='quote three hundred and sixty five'; //leap year quote

window.onload=function() {
displayQuote();
}
function displayQuote() {
today=new Date();
setYear=today.getUTCFullYear();
zero=new Date(setYear,0,1);
num=Math.floor((today-zero)/(1000*60*60*24));

document.getElementById('quote').firstChild.nodeValue=quotes[num];
}
</script>

</head>
<body>

<div id="quote">quote one</div>

</body>
</html>
...the hard work will be the insertion of all the 365 quotes required. :eek:
Luckily for me, that will be your task. ;)

coothead

Aishah
09-05-2007, 09:33 PM
Thank you for the above. Hope you have a good evening.

coothead
09-05-2007, 09:43 PM
No problem, you're welcome. ;)

coothead
09-05-2007, 10:37 PM
Hi there Aishah,

I did the coding OK, but obviously could not remember that there are 365 days in a a year. :eek:
So you will need 366 quotes.;)

coothead



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum