Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP .NET and JavaScript --passing values from textbox to script

Posted on 2006-06-21
3
Medium Priority
?
227 Views
Last Modified: 2010-05-18
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("StartTheTimer()", delay)
       
    }
}
//-->
</SCRIPT>

Thanks
0
Comment
Question by:vandy02
3 Comments
 
LVL 27

Accepted Solution

by:
Sammy Ageil earned 2000 total points
ID: 16957391
how about something like this
secs ="<%# intLength %>"; //where length is a variable declare in C#
or another option to use is secs=document.getElementById("textbox1").value; //where textbox1 is the ID of the textbox holding the value

HTH
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question