Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Error on page" in date/time comparison

Status
Not open for further replies.

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>
 
Hi

First fix the syntax error :
Code:
    [s]if nhours<(endHour-1)[/s]

    if (nhours<endHour-1)
And next time please post the code between [tt][ignore]
Code:
[/ignore][/tt] and [tt][ignore]
[/ignore][/tt] tags.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top