# January 4, 2013 at 5:26 am
here the scenario is
i have 7 images
i put those images one down other
by setting left margin -100px,zindex=0 ,position=relative of each image.
now i want to set the zindex property according to system time.
I tired to do this with the help of loop but i failed# January 4, 2013 at 3:43 pm
It sounds to me like you’re either:
A.) Wanting to set which image displays based on what the time of day is, so if it’s 07:00-10:00, show image A, if it’s 10:01-13:00, show image B, and so forth.
Or B.) Wanting to set a timed delay on the slider function, so that the images progress in sequence after a set period of time, say every x seconds or every x minutes.
Either of these cases is pretty simple, I should imagine. Situation A seems the most interesting (and if I’m reading your posts correctly, the most likely), so I’ll tackle that first.
Basically, it just grabs the current date/time, filters out the hour and plops that into a variable, which is then referenced by the switch to get 3-hour ranges, and whichever range matches applies a class of “current” to the respective element. That class sets the z-index.
I was far too lazy to make images, so I used colored backgrounds, and included an overlay with the a readout of the current time and comments in the HTML so you can see which lines up with which.
I hope this helps!
For B, just use setTimeout.
You must be logged in to reply to this topic.