Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Javascript; Change picture based on date

    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>
    Last edited by kelita928; 09-15-2011 at 03:40 AM.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    It would work ... but your code never adds or replaces the new picture anywhere ... that's why it will never show

    Add this code
    Code:
    document.write(picture);
    to the end of the posted code

  • Users who have thanked devnull69 for this post:

    kelita928 (09-15-2011)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •