Click to See Complete Forum and Search --> : auto daily image changer


fatbottoms
June 7th, 2005, 09:07 PM
i have a comic website with a cartoon which changes daily. i have a javascript for a 7-day changer, but would like to increase the days up to a month or more if possible.

here's my code for a 7-day change. how would i alter this to increase the days? or if someone could write some new code for daily image changer (up to a month), it would be greatly appreciated. here's my site, if you'd like to take a look. http://fatbottoms.atspace.com

<script>
<!--
var mondayimg="fb124.gif"
var tuesdayimg="fb125.gif"
var wednesdayimg="fb126.gif"
var thursdayimg="fb127.gif"
var fridayimg="fb121.gif"
var saturdayimg="fb122.gif"
var sundayimg="fb123.gif"
var mydate=new Date()
var today=mydate.getDay()
if (today==1)
document.write('<img src="'+mondayimg+'">')
else if (today==2)
document.write('<img src="'+tuesdayimg+'">')
else if (today==3)
document.write('<img src="'+wednesdayimg+'">')
else if (today==4)
document.write('<img src="'+thursdayimg+'">')
else if (today==5)
document.write('<img src="'+fridayimg+'">')
else if (today==6)
document.write('<img src="'+saturdayimg+'">')
else
document.write('<img src="'+sundayimg+'">')
//-->
</script>

Dr. Script
June 7th, 2005, 09:33 PM
<script type="text/javascript">

// img1.jpg is for the 1st of the month; img31.jpg is for the 31st of the month if it happens.
var pics = new Array('img1.jpg','img2.jpg','img3.jpg','img4.jpg', 'img5.jpg','img6.jpg','img7.jpg','img8.jpg','img9.jpg','img10.jpg', 'img11.jpg','img12.jpg','img13.jpg','img14.jpg','img15.jpg','img16.jpg', 'img17.jpg','img18.jpg','img19.jpg','img20.jpg','img21.jpg','img22.jpg', 'img23.jpg','img24.jpg','img25.jpg','img26.jpg','img27.jpg','img28.jpg', 'img29.jpg','img30.jpg','img31.jpg');

document.write('<img src="'+ pics[new Date().getDay()] +'">');

</script>That should do it. If you need any explanation on the coe, just holler.

Dr. Script