Solved

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

Posted on 2006-06-21
3
219 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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now