PDA

View Full Version : Image a day script help


grawss
07-09-03, 03:35 AM
I have the following script:

<SCRIPT LANGUAGE="JavaScript">
<!--
now=new Date();
day=now.getDay();
document.write("<IMG SRC='image/" + day + ".gif' WIDTH=250 HEIGHT=200 ALT='0.gif'>");
//-->
</script>

All I need to know is how to change it a little: I want it to display a picture for each day, except go on forever, so it never stops, and when there are no more pictures to load, it starts over.

Thank You,
Grawss

Henry
07-21-03, 05:36 AM
ok that seems pretty technical to me a simple option would just be to have a random image function a not what your looking for i know but its alot easier:

<script type="text/javascript">

image0="IMG URL"
href0="LINK URL"
alt0="NAME OF LINK"

image1="IMG URL"//remeber to change the numbers for every new img
href1="LINK URL"
alt1="NAME OF LINK"

len=2//this number is allways one up from the last image so if the image number is 7 then this is 8 easy

now=new Date()
now=now.getSeconds()
rnd=now%len

image=eval("image"+rnd)
href=eval("href"+rnd)
alt=eval("alt"+rnd)

document.write("<a href='" + href + "'>")
document.write("<img src='" + image + "' alt='" + alt + "' border=0></a>")
</script>

i know that doesnt help but it may come in handy one day

grawss
07-21-03, 04:12 PM
Thanks, that will do just fine.