Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Aysel Kaya   on Feb 13 In Asp.net Category.

  
Question Answered By: Chau Tran   on Feb 13

I am still
having a problem  though. First thing I'm a VBer, so
the c# is a little hard for me to transform. Second I
have created a project and was able to run the code
that Stephen sent me. Then I tried to put the script
in that I want to run. Now, here is my problem, the
line of code in my javascript  shown below. How do I
assign what the script is running  to Lbl_TimeCounter
in my aspx page? Does this make since?

js += "document.form[0]." + Lbl_TimeCounter.ClientID +
".value = timeValue";

Here is the script that I am using.



js = "<script language=JavaScript>\n";
js += "var timerID = null";
js += "var timerRunning = False";
js += "var startDate";
js += "var startSecs";
js += "function stopclock()";
js += "{";
js += "If (timerRunning) Then";
js += "clearTimeout(timerID)";
js += "timerRunning = False";
js += "}";
js += "function startclock()";
js += "{";
js += "startDate = New Date()";
js += "startSecs = (startDate.getHours() *
60 * 60) + (startDate.getMinutes() * 60)";
js += "+ startDate.getSeconds()";
js += "stopclock()";
js += "showtime()";
js += "}";
js += "function showtime()";
js += "{";
js += "var(Now = New Date())";
js += "var(nowSecs = (Now.getHours() * 60
* 60) + (Now.getMinutes() * 60) + Now.getSeconds())";
js += "var elapsedSecs = nowSecs -
startSecs;";
js += "var(hours = Math.Floor(elapsedSecs
/ 3600))";
js += "elapsedSecs = elapsedSecs - (hours
* 3600)";
js += "var(minutes =
Math.Floor(elapsedSecs / 60))";
js += "elapsedSecs = elapsedSecs -
(minutes * 60)";
js += "var(seconds = elapsedSecs)";
js += "var(TimeValue() = '' + hours)";
js += "timeValue += ((minutes < 10) ?
':0' : ':') + minutes";
js += "timeValue += ((seconds < 10) ?
':0' : ':') + seconds";
js += "// Update display";
js += "document.form[0]." +
Lbl_TimeCounter.ClientID + ".value = timeValue";
js += "timerID = setTimeout('showtime()',
1000)";
js += "timerRunning = True";
js += "}</script>";
return js;

Share: