|
|
Q236 How can I show a different image each day?
irt.org | Knowledge Base | JavaScript | Image | Q236 [ previous next ] Q236 How can I show a different image each day?What we need is some mechanism to choose the image to be displayed. The following script will always show 1.jpg:
This is similar to:
Now all we need to do is alter the value of the number. It would be easier if you had seven different images. That way we can display a different image for each day of the week:
This creates a date object and then gets the number of the day of the week, and then uses that to display the relevant image. If you have more than 7 images then you'll need to alter this, either using the day of the month or the day of the year, or maybe even the day of the millennium! Feedback on 'Q236 How can I show a different image each day?' |
-- div -->
|