...

View Full Version : Auto change image at certain date



vinny388
01-05-2007, 11:59 AM
Is there a script anywhere that will change an image on my website at a set date/time?

I have site that advertises a lot of fixtures, these are in a 220x160 banner form and I would like the image to change 2 or 3 times a week depending on what is coming up.

Any ideas?

Shaffer
01-05-2007, 02:15 PM
If you know JavaScript, here is the plan:
1. Make an array of images.
2. Get the current day of the month.
3. For once a month: If the current date matches 20 (4/20,5/20...), for instance, then get the next array property; For twice a month: If the current date matches 10 elseif the current date matches 20 do stuff in both conditional clauses.

Basically that.

Shaffer.

Philip M
01-05-2007, 03:16 PM
This is something I use and which changes to a different image each day
for 2 weeks (14 images).

<SCRIPT Language="JavaScript">
<!--
today = new Date();
day = today.getDay();
ddd = today.getDate();
if (ddd %2 ==0) { // if date divisible by 2
arday = new Array("ps36.jpg", "ps17.jpg", "ps40.jpg",
"ps13.jpg", "ps16.jpg", "ps26.jpg", "ps18.jpg");
document.write("<p align='center'><img src='" + arday[day] + "' width=271 height=168 border=0>");
}

else { // if date not divisible by 2
arday = new Array("ps03.jpg", "ps35.jpg", "ps07.jpg",
"ps27.jpg", "ps18.jpg", "ps30.jpg", "ps05.jpg");
document.write("<p align='center'><img src='" + arday[day] + "' width=271 height=168 border=0>");
}
// -->
</SCRIPT>

You could easily modify this to suit your needs. For eample, to change the image 3 times a week you could use:-

arday = new Array("day1.jpg", "day1.jpg", "day2.jpg",
"day2.jpg", "day3.jpg", "day3.jpg", "day3.jpg");

or whatever.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum