JRS: In article <44**********@news.tm.net.my>, dated Mon, 6 Mar 2006
03:52:30 remote, seen in news:comp.lang.javascript, magix
<ma***@asia.com> posted :
Do you have any javascript available for changing images according to time ?
let say Morning (7am-12pm), using images 1 (e.g morning.jpg)
Afternoon (12 - 6pm), using images 2 (e.g afternoon.jpg)
Night (6pm - 7am), using images 3 (e.g night.jpg)
If you had read the newsgroup FAQ, you should have found your way to js-
date0.htm#SS "Scheduled Selection" which can be simplified from hour-of-
week to hour-of-day.
It is not wise to divide the day into a.m. and p.m. within IT work; it
leads to unnecessary complication. Everyone should understand the
24-hour clock.
For only three images, you may prefer to use, rather than a List, a Case
statement, conditional statements, or a conditional expression such as
T<7 || T>18 ? "n.jpg" : T<12 ? "m.jpg" : "a.jpg"
You need to decide what you mean by, say, 6 pm; is it to be 18:00 UT,
18:00 Malaysian time, or 18:00 reader's time?
You also need to decide whether the image is chosen only when the page
loads, or whether it will be changed at 07:00, 12:00 and 18:00.
You could divide the day into equal intervals of Night, Morning,
Afternoon, and Evening, and use numbered images addressed as
Math.floor(T/6) + ".jpg"
or ((T/6)|0) + ".jpg"
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.