PDA

View Full Version : Timed Image Swap


senator818
12-25-2009, 02:47 AM
I'm trying to build a homepage where the main image automatically updates Bi-monthly. does anybody know of any scripts to do this(php or javascript)?

Having a heck of a time finding something simple, i'm not much of a scripter


Thanks in Advance,
Drew

davidj
12-27-2009, 12:02 AM
Are they the same images every month?

senator818
12-27-2009, 12:16 AM
yes
It is the main image that updates jan, march, may, july, sept, and nov.

I may have bit off more than I can chew, but.....

This is the script I am trying to work with....nothing seems to be happening?

<script>
// Function from http://www.developerfusion.co.uk/show/2310/
// used to create MultiDiension arrays quickly
function MultiDimensionalArray(iRows,iCols)
{
var i;
var j;
var a = new Array(iRows);
for (i=0; i < iRows; i++)
{
a[i] = new Array(iCols);
for (j=0; j < iCols; j++)
{
a[i][j] = "";
}
}
return(a);
}

function setDailyPic()
{
// Calendar Prep work
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year < 1000)
year+=1900
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;

// Define new picture array and fill it
myPictureArray = MultiDimensionalArray(12,32); // Defines an array 0..11, 0..31
// January
myPictureArray[0][1]="/images/january.jpg";
//march
myPictureArray[3][1]="/images/march.jpg";
// may
myPictureArray[5][1]="/images/may.jpg";
//july
myPictureArray[7][1]="/images/july.jpg";
//sept
myPictureArray[9][1]="/images/september.jpg";
// nov
myPictureArray[11][1]="/images/november.jpg";
//test
myPictureArray[12][25]="/images/logo.jpg";


//month=0; day=26; // Uncomment this line to test

// Display Picture

var pictureSRC = (myPictureArray[month][date])?myPictureArray[month][date]:"/images/monthdefault.jpg";
document.getElementById("myPicture").setAttribute("src",pictureSRC);
}
</SCRIPT>

</HEAD>
<BODY onLoad="setDailyPic()">
<img id='myPicture' src='/images/monthdefault.jpg'></img>
</BODY>



What am I doing wrong??

is there something I need to set on the webserver??

Please help, this is the last open item I have on this website I have designed and I cant grasp what is going wrong.





site is at
http://www.rocklandtutoring.com/RM%20Music/



cheers!
Drew