Katya85S
Programmer
- Jul 19, 2004
- 190
I’m trying to apply javascript Timer I found on the Internet. That script works perfectly, but when I added my script lines to that code I got “Error on page” message on the status bar.
What I’m trying to do: compare value from aspx’s textboxes txtEndDay and txtEndHour with system’s current Date and Hour stored in javascript variables ndate and nhours to worn users when just one hour has left and then when one minute has left until some End Time.
Could anybody help?
Thank you all in advance.
<SCRIPT language="JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000
var thetime=new Date()
var ndate=thetime.getDate()
var nhours=thetime.getHours()
var endDate=document.Form1.txtEndDay.value
var endHour=document.Form1.txtEndHour.value
function InitializeTimer()
{
// Set the length of the timer, in seconds
if (ndate!=endDate)
{
return
}
if nhours<(endHour-1)
{
return
}
if (nmins<59)
{
document.Form1.txtMsg.value="One Hour has left"
return
}
document.Form1.txtMsg.value="One minute has left"
secs = 60
StopTheClock()
StartTheTimer()
return
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
//-->
</SCRIPT>
What I’m trying to do: compare value from aspx’s textboxes txtEndDay and txtEndHour with system’s current Date and Hour stored in javascript variables ndate and nhours to worn users when just one hour has left and then when one minute has left until some End Time.
Could anybody help?
Thank you all in advance.
<SCRIPT language="JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000
var thetime=new Date()
var ndate=thetime.getDate()
var nhours=thetime.getHours()
var endDate=document.Form1.txtEndDay.value
var endHour=document.Form1.txtEndHour.value
function InitializeTimer()
{
// Set the length of the timer, in seconds
if (ndate!=endDate)
{
return
}
if nhours<(endHour-1)
{
return
}
if (nmins<59)
{
document.Form1.txtMsg.value="One Hour has left"
return
}
document.Form1.txtMsg.value="One minute has left"
secs = 60
StopTheClock()
StartTheTimer()
return
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
//-->
</SCRIPT>