473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to stop the time function

28
here iam using in my page time text field when page is the time is runing
ok its fine but when page is loded ofter the time will be stoped how....its posible ...plz tell me i want only the display time only the page loding time.

this is my script
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.         function det_time()
  4.    {
  5.    var d = new Date();
  6.    var c_hour = d.getHours();
  7.    var c_min = d.getMinutes();
  8.    var c_sec = d.getSeconds();
  9.    var t = c_hour + ":" + c_min + ":" + c_sec;
  10.    document.all.ctime.value = t;
  11.  
  12.  
  13.    }
  14.  
  15. setInterval("det_time()", 1000);
  16.  
  17.  
  18.     </script>
  19.  

<td width="18%" class="labeltext">Creation Time</td>

<td width="45%" class="blanktext"><html:text property="ctime" styleClass="text" size="10" maxlength="30" value="${U45.ctime}"readonly="true"/> </td>


ss
Aug 20 '07 #1
8 2129
vituko
48
setInterval returns an integer reference, you must store it.
Then, you can call clearInterval with this value as argument. From an event, for example.

Int_ref = setInterval (...) ;
clearInterval (Int_ref) ;
Aug 20 '07 #2
shyamg
28
setInterval returns an integer reference, you must store it.
Then, you can call clearInterval with this value as argument. From an event, for example.

Int_ref = setInterval (...) ;
clearInterval (Int_ref) ;

hallo this is not working i have to write like this

Expand|Select|Wrap|Line Numbers
  1.    function det_time()
  2.    {
  3.    var d = new Date();
  4.    var c_hour = d.getHours();
  5.    var c_min = d.getMinutes();
  6.    var c_sec = d.getSeconds();
  7.    var t = c_hour + ":" + c_min + ":" + c_sec;
  8.    document.all.ctime.value = t;
  9.     var Int_ref = setInterval (t) ;
  10.     clearInterval (Int_ref);
  11.  
  12.  
  13.    }
  14.  
  15.  
Aug 21 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

this is to start immediatly when the page is parsed:

Expand|Select|Wrap|Line Numbers
  1. function det_time() {
  2.     // some code
  3. }
  4.  
  5. var interval = window.setInterval(det_time, 10);
and then you have to call in the body's onload:

[HTML]<body onload="window.clearInterval(interval);">[/HTML]
kind regards
Aug 21 '07 #4
shyamg
28
hi gits ...


i want to stop the clock when the page is loding that time only run then its stop that time i want only using a text field in creation time .....that page loding time ..only


ss
Aug 21 '07 #5
gits
5,390 Expert Mod 4TB
??? you want to display the time from start of loading a page until it is loaded (and that is the moment when the body's onload fires!!) ... ??? in case i'm wrong please explain it in more detail ... what you want to do exactly. when do you want to call det_time the first time? when do you want to stop the interval? what do you want to display do you mean the time that the page needed to be loaded or the time when the page was loaded ... means: i want to view it 12:30 pm ... click a link or something ... and you want to display 12:30 pm now? ...

kind regards
Aug 21 '07 #6
shyamg
28
??? you want to display the time from start of loading a page until it is loaded (and that is the moment when the body's onload fires!!) ... ??? in case i'm wrong please explain it in more detail ... what you want to do exactly. when do you want to call det_time the first time? when do you want to stop the interval? what do you want to display do you mean the time that the page needed to be loaded or the time when the page was loaded ... means: i want to view it 12:30 pm ... click a link or something ... and you want to display 12:30 pm now? ...

kind regards
hi gits..


i want when ever jsp page is loded .it will be loded that time its time is runing i want fix that time when the page is loded that time only fix.ofter that time is stop but in my using text field in that time is continusly runing /........
Aug 21 '07 #7
shyamg
28
[HTML]<html>
<head>


</head>
<body>

<FORM NAME="myform">
<INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="10" VALUE=""
NAME="my_time">
</FORM>
<SCRIPT LANGUAGE="JAVASCRIPT">

function det_time()
{
var d = new Date();
var c_hour = d.getHours();
var c_min = d.getMinutes();
var c_sec = d.getSeconds();
var t = c_hour + ":" + c_min + ":" + c_sec;
document.myform.my_time.value = t;
}

setInterval("det_time()", 1000);


</SCRIPT>


</body>
</html>[/HTML]

this is my code in this when the page is loded the time will be stoped how.
Aug 21 '07 #8
gits
5,390 Expert Mod 4TB
hi ...

i added something to your code ... and you may see how to stop an interval:

[HTML]
<html>
<head>
</head>
<body>
<FORM NAME="myform">
<INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="10" VALUE="" NAME="my_time">
<input type="button" value="stop_time" onclick="clearInterval(interval_ref);"
</FORM>
<SCRIPT LANGUAGE="JAVASCRIPT">
function det_time()
{
var d = new Date();
var c_hour = d.getHours();
var c_min = d.getMinutes();
var c_sec = d.getSeconds();
var t = c_hour + ":" + c_min + ":" + c_sec;
document.myform.my_time.value = t;
}
var interval_ref = setInterval("det_time()", 1000);
</SCRIPT>
</body>
</html>
[/HTML]

as far as i understand you ... you don't need the interval ... simply call det_time in the onload-handler of your page, so the textfield shows the current time when the page is loaded ...

kind regards

ps: please use code tags when posting code
Aug 21 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: ScareCrowe | last post by:
Is there a way to stop the PHP cgi completely? I made a typo and got caught in an infinite loop. Usually I can wait until the execution time expires and fix the script but this time it kept going...
2
by: engsol | last post by:
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss loves the quick turn-around compared to C). Each log file may contain one...
8
by: Eric Osman | last post by:
My javascript program has reason to want to stop. For example, function A has 5 lines, the second of which calls function B, which has 5 lines, the first of which calls function C. But...
2
by: Adrian MacNair | last post by:
Hi I need some help if anyone can understand my crap javascript. The problem is that after the slideshow ends (reaches the end of array) it should stop, but the timeout doesn't clear and I can see...
2
by: Prasad | last post by:
Hi, I am writing a service which takes a long time to stop after the OnStop call is given by the Services Snap-in. The problem is I cannot cut down on the time that it takes to Stop. The Service...
13
by: python | last post by:
hello and thanks for reading this, i have been a dos/windows user using some form of the basic language for 30 years now. i own and run a small programming company and there is one feature that...
6
by: Xero | last post by:
Hi. I have created a 'stop watch' program. The working principle of the program is to declare an integer (say 'intTime'), which is initalized to zero. Once the user clicks the 'Start' button,...
1
by: umesh.vishwa | last post by:
I have a script tag in which I has set src for that script tag. But some time it takes time to load . So I need to stop this if it takes time. Please help me. <script language='JavaScript'...
51
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() ...
2
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.