Solved

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

Posted on 2006-06-21
3
221 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 earned 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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