Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    New Coder
    Join Date
    Jul 2007
    Location
    USA
    Posts
    83
    Thanks
    6
    Thanked 7 Times in 7 Posts
    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/

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, I'll have a look.

  • #4
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,694
    Thanks
    0
    Thanked 232 Times in 227 Posts
    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 ;

  • #5
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the above. Hope you have a good evening.

  • #6
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,694
    Thanks
    0
    Thanked 232 Times in 227 Posts
    No problem, you're welcome.

  • #7
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,694
    Thanks
    0
    Thanked 232 Times in 227 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •