www.webdeveloper.com
Results 1 to 5 of 5

Thread: Monthly changes

  1. #1
    Join Date
    Dec 2011
    Posts
    2

    Monthly changes

    For the past six months, I have been using a javascript file (kauai.js) to update a new photo daily on my Kauai Hawaii: A Daily Scenic Photographic Panorama web page. The URL is: http://www.davidallio.com/kauai/kauai-pn.htm

    Now, I would like to change the javascript file on a monthly basis, so that in January the javascript file used would be kauaijan.js and in February it would go to kauaifeb.js, and so forth for all 12 months. Is there a way to automate this process with javascript, if so, how? Otherwise, am I looking at something in CGI or another language?

    Suggestions, please...

  2. #2
    Join Date
    Nov 2010
    Posts
    1,086
    do your files have to be named that way? it would be easier if they were kauai0.js, kauai1.js, etc

    not impossible either way, though...
    Last edited by xelawho; 12-22-2011 at 04:04 PM.

  3. #3
    Join Date
    Nov 2010
    Posts
    1,086
    well, assuming that you can't rename the files, you can put this in the head of your html, where you are loading your other scripts...

    Code:
    <script type = "text/javascript">
    var month=new Date().getMonth()
    months=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]
    document.write(
          '<sc' + 'ript type="text/javascript" '
        + ' src="kauai' + months[month] + '.js">'
        + '</sc' + 'ript>');
    </script>

  4. #4
    Join Date
    Dec 2011
    Posts
    2
    Quote Originally Posted by xelawho View Post
    do your files have to be named that way? it would be easier if they were kauai0.js, kauai1.js, etc

    not impossible either way, though...
    Thank you... I had not thought about adding the '<sc' + 'rpit>' to the filename... Many Mahalo...

  5. #5
    Join Date
    Nov 2010
    Posts
    1,086
    'A'ole pilikia

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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