...

View Full Version : Javascript; Change picture based on date



kelita928
09-14-2011, 11:18 AM
I'm new to coding and recently undertook the position as my school district's webmaster. We use a six day schedule where the days are labeled A-F. I want to be able to display the Today is...A graphic based on the date. I tried some scripts from other forums, but it does not appear to be working. Any suggestions? TY
<code>
<script language="javascript">
<!--
var picture='';
mytime=new Date();
mymonth=mytime.getMonth()+1;
mydate=mytime.getDate();
if (mymonth==9 && mydate==13){picture="<img src=/images/d.gif>";
}
if (mymonth==9 && mydate==14){picture="<img src=/images/e.gif width=150 height=150 alt=E>";
}
if (mymonth==9 && mydate==15){picture="<img src=/images/f.gif width=150 height=150 alt=F>";
}
if (mymonth==9 && mydate==16){picture="<img src=/images/A.gif width=150 height=150 alt=A>";
}
if (mymonth==9 && mydate==19){picture="<img src=/images/B.gif width=150 height=150 alt=B>";
}
if (mymonth==9 && mydate==20){picture="<img src=/images/c.gif width=150 height=150 alt=C>";
}
//-->
</script></code>

devnull69
09-14-2011, 12:22 PM
It would work ... but your code never adds or replaces the new picture anywhere ... that's why it will never show

Add this code


document.write(picture);

to the end of the posted code



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum