Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-31-2007, 03:59 PM   PM User | #1
Aishah
New to the CF scene

 
Join Date: Jul 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Aishah is an unknown quantity at this point
Random Text box (fpr 24 hours per text)

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.
Aishah is offline   Reply With Quote
Old 09-01-2007, 06:00 AM   PM User | #2
lithriel
New Coder

 
Join Date: Jul 2007
Location: USA
Posts: 83
Thanks: 6
Thanked 7 Times in 7 Posts
lithriel is on a distinguished road
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/
__________________
The End of the Internet
lithriel is offline   Reply With Quote
Old 09-02-2007, 12:16 AM   PM User | #3
Aishah
New to the CF scene

 
Join Date: Jul 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Aishah is an unknown quantity at this point
Thanks, I'll have a look.
Aishah is offline   Reply With Quote
Old 09-02-2007, 08:57 AM   PM User | #4
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,551
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there Aishah,

this simple script will display a different quote for every day of the year....
Code:
<!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.
Luckily for me, that will be your task.

coothead

Last edited by coothead; 09-02-2007 at 12:01 PM.. Reason: missed out a ;
coothead is offline   Reply With Quote
Old 09-05-2007, 08:33 PM   PM User | #5
Aishah
New to the CF scene

 
Join Date: Jul 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Aishah is an unknown quantity at this point
Thank you for the above. Hope you have a good evening.
Aishah is offline   Reply With Quote
Old 09-05-2007, 08:43 PM   PM User | #6
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,551
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
No problem, you're welcome.
coothead is offline   Reply With Quote
Old 09-05-2007, 09:37 PM   PM User | #7
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,551
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there Aishah,

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

coothead
coothead is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:50 PM.


Advertisement
Log in to turn off these ads.