www.webdeveloper.com
Results 1 to 3 of 3

Thread: Photo change after 1 minut

  1. #1
    Join Date
    Mar 2014
    Posts
    2

    Photo change after 1 minut

    Hello guys,
    I need a script that automatically change the picture without page refresh
    every minute based on the PC clock

    Example:
    I have a database with timestamp and photo

    based on the clock pc time the script connect to db recover image and display until next minut

    so 1730 1 photo
    1731 another photo
    1732 other photo

    etc

    any idea or suggestion?

    I have found this code on internet but I'm not able to use it. COuld u help me?

    <img />
    <script>
    var start = new Date().getTime(),
    i = 0,
    //get the node of the image to change
    img = document.getElementsByTagName('IMG')[0];

    setInterval(function(){
    //what time is now
    var now = new Date().getTime();
    if(now - start > 60000){
    //initialize the counter
    start = now;
    //overlay with 0's -> substr(-4)
    //rotate on 1440 with a modulo -> i++ % 1440
    img.src = ('000' + (i++ % 1440 + 1)).substr(-4) + '.jpg';
    }
    }, 10000); //check every 10 sec
    </script>

    Thanks

    Claudio

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    Quote Originally Posted by solocla View Post
    ...I'm not able to use it...
    this is not a javascript error
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Sep 2008
    Location
    Jackson MS
    Posts
    373
    Try this resourse: www.codelifter.com/main/javascript/slideshow2.html I use it for a slideshow of cats: cats on a garden chessboard.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles