Forum Moderators: open

Message Too Old, No Replies

Daily Image Update

         

pHJason

6:12 pm on Oct 7, 2010 (gmt 0)

10+ Year Member



Is there a Javascript that exists that basically tells my site to change a specific image depending on what day of the week it is?

Practically I run a theater, and I would like there to be a Now Playing section that pulls up the appropriate image for that night's show.

Thanks in advance.

Fotiman

6:24 pm on Oct 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld! In your case, the images are really part of the content. This is something that is best handled server-side, not with JavaScript. Otherwise, people visiting your site with JavaScript disabled may not be able to view the correct content. What sort of server side platform is your site running on (PHP? ASP? etc.)? My recommendation would be to research a server side solution.

pHJason

6:45 pm on Oct 7, 2010 (gmt 0)

10+ Year Member



We are PHP, shall I go ask there?

Fotiman

6:55 pm on Oct 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's how I would approach it. Getting the current date in PHP is pretty straight forward:
[php.net...]

I would get the day of the week, and then depending on the result, display the appropriate data. For example:

<?php
$day = date("N");
switch ($day) {
case ("1"):
//Monday
break;
case ("2"):
// Tuesday
break;
case ("3"):
//Wednesday
break;
case ("4"):
//Thursday
break;
case ("5"):
//Friday
break;
case ("6"):
//Saturday
break;
case ("7"):
//Sunday
break;
}
?>