HELP! Image based on the day's date?

    Date: 04/20/05 (Javascript Community)    Keywords: java

    What the most efficient way to insert an image based on the day's date?

    For example, on Monday April 18, 2005 it would generate:
    [img src="http://www.domain.com/images/20050418.jpg"]


    I ended up doing this ...
    [SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"]
    [!--
    var today = new Date();
    var Year = takeYear(today);
    var Month = leadingZero(today.getMonth()+1);
    var Day = leadingZero(today.getDate());
    function takeYear(theDate)
    {
    x = theDate.getYear();
    var y = x % 100;
    y += (y < 38) ? 2000 : 1900;
    return y;
    }
    function leadingZero(nr)
    {
    if (nr < 10) nr = "0" + nr;
    return nr;
    }
    document.write ('[img src="http://www.domain.com/images/' + Year + Month + Day + '.jpg"]');
    // --]
    [/SCRIPT]

    But I still need a hand writing code to check to see that the image exists before inserting it, and if not continuing to subract a day from the date until it found an image.

    Anyone have any idea how I could do this?

    Source: http://www.livejournal.com/community/javascript/63164.html

« manual slideshow with... || Why Hello... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home