I don't mean to sound patronising but - http://www.google.co.uk/search?sourceid ... ript+timer
That's where I would start
It is currently Thu Apr 18, 2024 7:42 am
while(IsRunning())
{
//Do timer stuff
}
bool IsRunning()
{
if(time = end time)
return false;
else
retun true;
}
caseyw wrote:Thanks, but I have been looking around, I've found several tutorials, but for some odd reason it always seems like it's about to work then it breaks. I think I might have messed a few other things up, so I'll keep trying.
caseyw wrote:My code for the javascript is inside my HTML in the head. It's in one of my earlier posts. Check up some. If you meant something else then please specify please.
<html>
<head>
<!-- JavaScript -->
<script type="text/javascript">
function updateTime() {
// Initilization(s)
now = new Date();
timetype = "null";
// Definitions
now_sec = now.getSeconds();
now_min = now.getMinutes();
now_hur = now.getHours();
// Single Digit Correction
if (now_sec<10) {
now_sec = "0" + now_sec;
}
if (now_min<10) {
now_min = "0" + now_min;
}
if (now_hur<10) {
now_hur = "0" + now_hur;
}
// Determine AM & PM
if (now_hur>=12) {
time_type = "PM";
} else {
time_type = "AM";
}
// Combine all parts to create Current Time
cur_tim = now_hur + ":" + now_min + ":" + now_sec + " " + time_type;
// Change timer span to current time
document.getElementById("timer").innerHTML = cur_tim;
// Update interval
setTimeout("updateTime()", 0);
}
</script>
<!-- Stylesheets -->
<link rel="stylesheet" href="default.css" media="all" />
</head>
<body onload="updateTime();">
<span id="timer"></span>
</body>
</html>
Return to Web Design & Development
Users browsing this forum: No registered users