Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-06-21
3
Medium Priority
?
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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