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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer not working

Status
Not open for further replies.

VisualBasicHelp

Programmer
Sep 7, 2005
74
GB
I have written a timer for my application,but because of prompt or alert button, it is not able to work properly.

My timer function is -

var secs
var timerID = null
var timerRunning = false
var delay = 1000
var counter=0

function InitializeTimer()
{
// Set the length of the timer, in seconds
counter=counter+1
secs = 10
StopTheClock()
StartTheTimer()
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
// Here's where you put something useful that's
// supposed to happen after the allotted time.
// For example, you could display a message:
alert("You have just wasted 10 seconds of your life.")
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}

I am calling from another function --

function confirmation()
{
alert(counter)
secs = 10
Kit_ID=prompt(document.show_randomize_trans_IWR.msg.value," ");
kitGiven=document.show_randomize_trans_IWR.kitGiven.value;
confirmMsg=document.show_randomize_trans_IWR.confirmMsg.value;
noConfirmMsg=document.show_randomize_trans_IWR.noConfirmMsg.value;
if(Kit_ID==kitGiven)
{
alert(confirmMsg);
return true;
}
else
{
InitializeTimer()
if(counter<3)
{
alert(noConfirmMsg);
confirmation();
}
}
}

Can you please help me out in this, just because of this I am fully stuck
 
when

prompt document.show_randomize_trans_IWR.msg.value," ");

comes, the timer is stopped, can I make a timer which will keep this prompt for 10 secs and after that play a message and comes back again to the prompt and after that again plays a message and comes back to the prompt and for the third time it should come back to the file from which prompt generated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top