10-30-2008
stopclock coding in javascript.
i have got a problem in this coding.i have got start/pause in the same button.wen i open that page the stopclock runs automatically.wen i click pause it get paused in the frontend textbox bt running in the backend.wen i again click that start itz starting from the time without considering that pause.i need a quick help.i want my stopclock to pause wen n click that button and start wen clicked should start from the time where itz was paused.
here is my coding.
<scripttype="text/javascript">
var base = 60;
var clocktimer,dateObj,dh,dm,ds,ms;
var readout='';
var h=1;
var m=1;
var tm=1;
var s=0;
var ts=0;
var ms=0;
var show=true;
var init=0;
var mPLUS=new Array('m0','m1','m2','m3','m4','m5','m6','m7','m8','m9');
var ii=0;
window.onload = function()
{
findTIME();
}
function clearALL() {
clearTimeout(clocktimer);
h=1;m=1;tm=1;s=0;ts=0;ms=0;
init=0;show=true;
readout='00:00:00.00';
document.getElementById("ctl00_cphCMSContent_clock").value=readout;
}
function addMEM() {
if (init>0) {
findTIME()
var CF=document.getElementById("ctl00_cphCMSContent_clock");
document.getElementById("ctl00_cphCMSContent_m0").value=readout;
}
}
function startTIME() {
var cdateObj = new Date();
var t = (cdateObj.getTime() - dateObj.getTime())-(s*1000);
if (t>999) { s++; }
if (s>=(m*base)) {
ts=0;
m++;
} else {
ts=parseInt((ms/100)+s);
if(ts>=base) { ts=ts-((m-1)*base); }
}
if (m>(h*base)) {
tm=1;
h++;
} else {
tm=parseInt((ms/100)+m);
if(tm>=base) { tm=tm-((h-1)*base); }
}
ms = Math.round(t/10);
if (ms>99) {ms=0;}
if (ms==0) {ms='00';}
if (ms>0&&ms<=9) { ms = '0'+ms; }
if (ts>0) { ds = ts; if (ts<10) { ds = '0'+ts; }} else { ds = '00'; }
dm=tm-1;
if (dm>0) { if (dm<10) { dm = '0'+dm; }} else { dm = '00'; }
dh=h-1;
if (dh>0) { if (dh<10) { dh = '0'+dh; }} else { dh = '00'; }
readout = dh + ':' + dm + ':' + ds + '.' + ms;
if (show==true) {
//alert(document.frmShowSpotView);
//document.clockform.clock.value = readout;
document.getElementById("ctl00_cphCMSContent_clock").value=readout;
}
clocktimer = setTimeout("startTIME()",1);
}
function findTIME()
{
if (init==0) {
dateObj = new Date();
startTIME();
init=1;
}
else
{
if(show==true) {
show=false;
}
else
{
show=true;
}
}
}
</script>
<asp:TextBoxrunat="server"ID="clock"Text="00:00:00.00"Width="174px"Height="35px"></asp:TextBox>
<inputname="clearer"type="button"value="Reset"onclick="clearALL()">
<inputname="starter"type="button"value="Start/Pause"onclick="findTIME();"
inputname="marker" type="button"value="SET"onclick="addMEM()">
7 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
I apologise because I had pasted this question in the newbies forum first (because i am a bit of a newbie) but thought it might be better suited in here
if i have to sepearate parameters can I use this syntax especially the or part (||) and is this correct
if (6 Replies)
Discussion started by: w33man
6 Replies
2. Shell Programming and Scripting
I would like to start coding on my mac, but I'm getting an error when I attempt to execute my script
-bash : testscript: command not found
I have verified that the #! line points to the correct directory.
If you have some insight it would be greatly appreciated!
- D (1 Reply)
Discussion started by: DKNUCKLES
1 Replies
3. UNIX for Dummies Questions & Answers
What this command sed "/*$/d" means?
izzit add commas to numeric strings, changing "1234567" to "1,234,567" ? (1 Reply)
Discussion started by: rita1985
1 Replies
4. Shell Programming and Scripting
HI,
Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ?
Format of data:
YYYYMMDD065959.dsk.log
YYYYMMDD235959.dsk.log
currently both are loaded together. Need to separate them as above format.
Thanks in advance.
... (1 Reply)
Discussion started by: crazydude80
1 Replies
5. Windows & DOS: Issues & Discussions
HI,
Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ?
Format of data:
YYYYMMDD065959.dsk.log
YYYYMMDD235959.dsk.log
currently both are loaded together. Need to separate them as above format.
Thanks in advance.
... (2 Replies)
Discussion started by: crazydude80
2 Replies
6. Programming
I have been starting
What wrong with this? ive been staring at it but not coming up with anything
im getting syntax error, unexpected T_RETURN where it says " return $result; "
<?php
function add_subtract ($value1, $value2) {
$add = $value1 + $value2;
$subtract = $value1 -... (2 Replies)
Discussion started by: AimyThomas
2 Replies
7. What is on Your Mind?
"Naive coding."
(Apologies for any typos.)
I came across this phrase a couple of weeks ago and it has made me decide to set off a discussion.
I had never heard of it before but I did some research and discovered that I probably fall into this category.
My phrase is: "I code to work, not... (10 Replies)
Discussion started by: wisecracker
10 Replies