SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation image change at certain time of day

    im not sure if this would be done in javascript but im just assuming...here's what i need....i am doing a site for a radio station and there will be a little section that says "on air now" and it will have a picture of the DJ that is currently on the air. what i need is for the picture to change according to the time they are on the air...ie. Kris' picture would be up from 9am - 11am
    Scotts picture would be up from 11am - 2pm
    etc. etc.

    so i need those pictures to change at that time of the day... can anybody point me in the right direction?!?!

    thanks..

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    try google b4 here

    getting the time of day is quite a simple process.

    I searched Google with your opening sentance....
    'image change at certain time of day '
    and it came up with loads of good stuff...

    Give it a try.....
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rriiggghttt

    if coming up with "loads of good stuff" includes 800 # services, high school message boards, and stock trade info then alright...but thats not good stuff in my book....in the first 3 pages there was ONE page that had anything to do w/ what i was lookin for...and i sorta found what i was lookin for but not exactly...so don't say "try google before here" when google doesn't really have what im lookin for....

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Boo-ya!
    http://www.google.com/search?sourcei...et+time+of+day

    Google's never wrong!

    --Vinnie

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var now = new Date();
    var hour = now.getHours();
    
    if(hour >= 9 && hour <= 11){
    	src = "kris.jpg";
    }else if(hour >= 11 && hour <= 14){
    	src = "scott.jpg";
    }else{
    	src = "default.jpg";
    }
    
    document.write('<img src="'+src+'" width="50" height="50">');
    travis

  6. #6
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Always try google and get the latest.....

    Always try your search with Google first.
    It is VERY good for website tutorials, if you define your searches, and it will show you new syntax that may have only just been created or made cross browser.

    putting '.' inbetween words makes google look for exact phrase

    so 'time.of.day javascript' will look for documents containing the exact phrase 'time of day' and include the word javascript.

    Eg getElementById has only just been made to work cross browser, and only the people looking for a function will find that out. People who hve been programming for a long period have a set way of doing things, so do not need to search. Therefor they might not learn new syntax.

    I recommend that the parts of your program that seem long winded, repeat your searches in the future, things are always getting condensed!! I now use a very good function for sound, but it took me a year to find!!!

    And have fun...... If your gonna be staring at the screen for ages make it fun!!!
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


Bookmarks

Posting Permissions

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