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.
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)
This will output (depending on the day):