www.webdeveloper.com
Results 1 to 4 of 4

Thread: Rotating image expire

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    Rotating image expire

    Yes, I am trying to create a web page that displays images in a certain directory and expire on the day of the file name.


    files with the file names of 10-10-12.jpg, 11-13-12.jpg, 12-10-12.jpg, 01-12-13.jpg

    I would like to read the directory and fine the newest date in this case is 10-10-12.jpg and display it until lets say 10:00pm of that day, then from 10:01pm it finds the next file of 11-13-12.jpg and display it until 10:01pm of the file date

    Thanks

  2. #2
    Join Date
    Oct 2012
    Location
    Gujarat, India.
    Posts
    35
    Well, i think you want some image to appear on some date (or some time). Means you want to change them time by time. (Till I know) You can't do that with JUST file names. You have to use JavaScript and also specify that on which time you want to show which image, Okay?

    First let us guess that you have images named "img1.jpg" , "img2.jpg" & "img3.jpg" and you want them to appear on 11th, 12th & 13th October, 2012 respectively. Then in your HTML:

    HTML Code:
    <div><img "changeByTime" src="" onload="change()" />
    And your JavaScript:

    Code:
    function change() {
    /*Variable declaration */
    var today= new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1;    //We need add 1 because Jan = 0, Feb = 1, and so on.
    var yyyy = today.getFullYear();
    
    /*Time to rock on */
    
    if (dd == 11 && mm == 10 && year = 2012) {
         document.getElementById("changeByTime").innerHTML.src = "img1.jpg";
    }
    else if (dd == 12 && mm == 10 && year = 2012) {
         document.getElementById("changeByTime").innerHTML.src = "img2.jpg";
    }
    
    else if (dd == 13 && mm == 10 && year = 2012) {
         document.getElementById("changeByTime").innerHTML.src = "img3.jpg";
    }
    Please note that i haven't checked code. Tell me if any problem occurs.

  3. #3
    Join Date
    Mar 2011
    Posts
    1,137
    HTML/JavaScript can't read directories. You'll need a script (PHP, Perl, Ruby, etc.) on the server that can handle that task. There are several different ways of getting that information to your webpage. You could make the webpage itself a PHP script that simply generates the appropriate JavaScript code required, or you could use JavaScript/AJAX to retrieve the data from the script.
    Rick Trethewey
    Rainbo Design

  4. #4
    Join Date
    Oct 2012
    Posts
    2
    Yes, something along those lines is what I am looking for. But what I want to do is to be able to upload files in a specific directory and give the pictures file names of the date that they will expire and have the script be able to find the next picture automaticaly and display it until the date of the file name and move to the next picture. I am trying to do this for a friend that all he wants to be able to do is put up the pictures and let the script to all the work.



    Thanks,

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