More work on the digital clock code! Trussville AL

Today we begin playing around with replacing those image tags with the correct numbers, depending on what time it is.

Local Companies

Martin Software Associates Inc
205-871-7766
4 Office Park Cir
Birmingham, AL
ExpertsHired.com
205-419-5609
1116 20th St. South #221
Birmingham, AL
Arbitron Inc
205-977-6100
3500 Colonnade Pkwy
Birmingham, AL
Westglenn Software
205-870-3118
2100 Southbridge Pkwy
Birmingham, AL
Exact Software North America
205-980-5270
3000 Eagle Point Corporate DR
Birmingham, AL
Priority Software
205-838-7061
9006 4th Ave S
Birmingham, AL
Visual Solutions Inc
205-930-5540
2217 10th CT S
Birmingham, AL
Xcitek Solutions Plus LLC
205-439-5700
3595 Grandview Pkwy
Birmingham, AL
Appsolute Genius
(205) 266-7981
3800 Colonnade Parkway
Birmingham, AL
Achaia Solutions
205-437-9960
117 Narrows Creek DR
Birmingham, AL

provided by: 
Originally published at Internet.com


Tips...

Last week we learned the NAMEs attached to each of the HTML image tags. Today we begin playing around with replacing those image tags with the correct numbers, depending on what time it is.

Here's the code

The time is grabbed from the user's browser, so there's no need to worry about daylight savings time or time zones. As long as the viewer has his or her browser set correctly, you're good to go. If they don't, well, you can't help that.

Let's start at the top of the script just below the loading loop and code: function clock() { dates=new Date(); hour=dates.getHours(); min=dates.getMinutes(); sec=dates.getSeconds(); if(hour < 12) { amPM=am.src; } if(hour > 11) { amPM=pm.src; hour=hour-12; } if(hour == 0) { hour=12; } if(hour < 10) { document["tensHour"].src="http://www.developer.com/dgtbl.gif"; document["Hour"].src=d[hour].src; } if(hour > 9) { document["tensHour"].src=d[1].src; document["Hour"].src=d[hour-10].src; } if(min < 10) { document["tensMin"].src=d[0].src; } if(min > 9) { document["tensMin"].src=d[parseInt(min/10,10)].src; } document["Min"].src=d[min%10].src; if(sec < 10) { document["tensSec"].src=d[0].src; } if(sec > 9) { document["tensSec"].src=d[parseInt(sec/10,10)].src; } document["Sec"].src=d[sec%10].src; document["amPM"].src=amPM; setTimeout("clock();",100); } ...

Read article at Internet.com site

Featured Local Company

Priority Software

205-838-7061
9006 4th Ave S
Birmingham, AL

Related Local Event
Going Green Awards
Dates: 10/1/2009 - 10/1/2009
Location: Sheraton
North Birmingham, AL
View Details

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML