vandy02
asked on
ASP .NET and JavaScript --passing values from textbox to script
I am working in C# and JavaScript with an 'onload' event and a JavaScript time. I am able to start and stop the timer in the asp page with buttons. I am able to start the time on the page load with onload = InitializeTimer(). However, I would like to be able to set the time value dynamically. In other words, I would like to have a textbox where I could enter 20 followed by pressing the start button which would then call InitializeTimer() but pass a value to set 'secs' from 'secs=10' to the passed value. If I can get this process to work I would then just have the onload event pass in a number as well 'InitializeTimer(10)' for it to work. Any ideas how this could work.
<SCRIPT language="JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000
var runtime
function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 10
StopTheTimer()
StartTheTimer()
}
function StopTheTimer()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheTimer()
InitializeTimer()
//document.frmManageQueue. submit();
__doPostBack("AUTOREFRESH" ,"");
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheT imer()", delay)
}
}
//-->
</SCRIPT>
Thanks
<SCRIPT language="JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000
var runtime
function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 10
StopTheTimer()
StartTheTimer()
}
function StopTheTimer()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheTimer()
InitializeTimer()
//document.frmManageQueue.
__doPostBack("AUTOREFRESH"
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheT
}
}
//-->
</SCRIPT>
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.