1

I have a modal which needs to popup once a day for 10 days - the images must appear in sequence. The modal hold an image which needs to change every day and loop over that 10 day period.

I have a solution to part but not all. I have an array which will show every hour - I need to set an interval in between the images for a 24 hour period. I cant seem to get anything to work which tells me my syntax is incorrect.

Here is the working code so far:

function showImageSelection() {
var myImage = document.getElementById('myimage');
var myPath = 'images/';

var myImageSelection = new Array();
myImageSelection[0] = 'bus.png';
myImageSelection[1] = 'agri.png';
myImageSelection[2] = 'art.png';
myImageSelection[3] = 'fin.png';

var myTime = new Date();
var myHour = myTime.getHours();

myHour /= 6;
myHour = Math.floor(myHour);

var imagePath = myPath + myImageSelection[myHour];

myImage.src = imagePath;
myImage.alt = myImageSelection[myHour];
myImage.title = myImageSelection[myHour];
}

Any help would be appreciated!

  • By the way - it is currently set to appear 4 times a day. – garvon-77 Jul 4 '16 at 0:26
  • I believe I need a cookie to achieve this - is this right? – garvon-77 Jul 6 '16 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.