this is the thread where you ask questions so dorky that you have to direct people to the "HTML playground" forum

Message Bookmarked
Bookmark Removed
WARNING: NON-PROGRAMMER ATTEMPTING TO PROGRAM

answer here or there, i don't care, this is driving me batty

javascript: date-conditional image swapping

Tracer Hand (tracerhand), Thursday, 3 April 2003 20:21 (twenty-one years ago) link

Tracer:

How about something like this? (don't know if ILX is going to screw up my script)


<script language="JavaScript"><!--
var day = new Date();
var month = day.getMonth();
document.write('<img src="images/' + month + '.jpg" alt="This is month number ' + month + '">');
//--></script>

Paul Eater (eater), Thursday, 3 April 2003 20:38 (twenty-one years ago) link

Or am I misunderstanding your purpose with the on and off images?

Paul Eater (eater), Thursday, 3 April 2003 20:40 (twenty-one years ago) link

All the images are already on the page, but in their "off" states. I want to turn "on" the image for the current month without any user input, like when the page loads.

I've actually managed to do it, but with a long list of "if - else" statements which bogs the whole thing down and makes the page take forever to load.

Tracer Hand (tracerhand), Thursday, 3 April 2003 20:48 (twenty-one years ago) link

Okay I made one more stab; now I'm off to dinner.

Paul Eater (eater), Thursday, 3 April 2003 21:13 (twenty-one years ago) link

Thanks Paul, I'm checking it out right now!

Tracer Hand (tracerhand), Thursday, 3 April 2003 23:03 (twenty-one years ago) link


You must be logged in to post. Please either login here, or if you are not registered, you may register here.