treehouse : what would you like to learn today?
Web Design Web Development iOS Development

How to assign a different background image everyday

  • Can anybody point me to a tutorial on how to assign a different background image each day? Or if anybody can show me how to do this, I'd greatly appreciate since I'm really dumb in coding. Thank you.
  • Wow it's been 3 days and still no replies? Kindly just point me to a tut/s for my query.
  • Yo man try not to demand things...


    function chgDailyImg()
    {
    var imagearray = new Array();
    imagearray[0] = "sundaypic.jpg";
    imagearray[1] = "mondaypic.jpg";
    imagearray[2] = "tuesdaypic.jpg";
    imagearray[3] = "wednesdaypic.jpg";
    imagearray[4] = "thursdaypic.jpg";
    imagearray[5] = "fridaypic.jpg";
    imagearray[6] = "saturdaypic.jpg";

    var d = new Date(); /*** create a date object for use ***/
    var i = d.getDay(); /*** use the date object to get the day of the week - this will be a number from 0 to 6 - sunday=0, saturday=6 -it's the way counting works in javascript it starts at 0 like in the arrays ***/
    document.getElementById("dailyImg").src = imagearray[i];
    }




    (not my code)

  • Sorry man, I'm in a desperate situation. But thanks a lot, will try this out and will let you know.
  • PHP Version:
    <style type="text/css">
    body{background: url(images/<?php
    $day = strtolower(strftime('%A'));
    echo $day;
    ?>.jpg) no-repeat left top;}
    </style>

    This will output (depending on the day):
    body{background: url(images/wednesday.jpg) no-repeat left top;}