Hookster264
In Runtime
- Messages
- 162
- Location
- Denver, CO
I am trying to build a webpage that includes the multiple copies of the same javascript. The script is for time zone clocks. I want to display a counting clock for multiple cities in a list. Some of the cities will be in the same time zone and I want a new clock with each city.
I resaved the script with varying Timezone offsets for each time zone and named them according to their time zone and daylight/standard.
When I recall each script with the <span> tag, I can only get one copy of each script to run.
Is there a way to run multiple copies of the same script on one page? Is there an easier way to call on the scripts than to use the span tag?
my script is below:
And recall it in the body:
Current Time <br /><span id="mdt" class="time">Â </span><br /> Mountain Daylight (MDT)
I resaved the script with varying Timezone offsets for each time zone and named them according to their time zone and daylight/standard.
When I recall each script with the <span> tag, I can only get one copy of each script to run.
Is there a way to run multiple copies of the same script on one page? Is there an easier way to call on the scripts than to use the span tag?
my script is below:
Code:
<script>
function mdt ()
{
var TimezoneOffset = -6
var localTime = new Date()
var ms = localTime.getTime()
+ (localTime.getTimezoneOffset() * 60000)
+ TimezoneOffset * 3600000
var time = new Date(ms)
var hour = time.getHours()
var minute = time.getMinutes()
var second = time.getSeconds()
var temp =
((hour < 10) ? "0" : "") + hour + ":"
if(temp.length==1) temp = " " + temp
temp += ((minute < 10) ? "0" : "") + minute + ":"
temp += ((second < 10) ? "0" : "") + second
document.getElementById("mdt").firstChild.nodeValue = temp;
setTimeout("mdt ()",1000)
}
</script>
<body onload="mdt ()">
Current Time <br /><span id="mdt" class="time">Â </span><br /> Mountain Daylight (MDT)