VisualBasicHelp
Programmer
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
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