Solved

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

Posted on 2006-06-21
3
222 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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