J
Joseph S
I am having problems with the following countdown script. For some reason,
the number of months is occasionally wrong. I can't quite put my finger on
the problem. Any assistance or recommendation from someone more knowlegable
than me would be appreciated. Thanks much.
<script>
ty=2005;to=08;td=31;th=24;tm=0;ts=0;
function e(){
ny=0;no=0;nd=0;nh=0;nm=0;ns=0;n=new Date();
if(n.getYear()>ty){t.s.value=0;t.m.value=0;t.h.value=0;t.d.value=0;t.o.value
=0;t.y.value=0;}
else{
ns=ns+ts-n.getSeconds();if(ns<0){ns=60+ns;nm=-1;}t.s.value=ns;
nm=nm+tm-n.getMinutes();if(nm<0){nm=60+nm;nh=-1;}t.m.value=nm;
nh=nh+th-n.getHours();if(nh<0){nh=24+nh;nd=-1;}t.h.value=nh;
nd=nd+td-n.getDate();if(nd<0){
x=n.getMonth();
if(x==0||x==2||x==4||x==6||x==7||x==9||x==11){nd=31+nd;}
if(x==3||x==5||x==8||x==10){nd=30+nd;}
if(x==1){if(n.getYear()/4-Math.floor(n.getYear()/4)==0){nd=29+nd;}else{nd=28
+nd;}}
}no=-1;t.d.value=nd;
no=no+to-n.getMonth();if(no<0){no=11+no;ny=-1;}t.o.value=no;
ny=ny+ty-n.getYear();if(ny<0){t.y.value=0;}else{t.y.value=ny;setTimeout("e()
",1000);}
}
}
</script>
Example:
http://members.cox.net/icystorm/retire
---------------
Joseph
(e-mail address removed)
(Please remove both occurrences of "nospam" to reply via email, or simply
reply here in USENET instead.)
the number of months is occasionally wrong. I can't quite put my finger on
the problem. Any assistance or recommendation from someone more knowlegable
than me would be appreciated. Thanks much.
<script>
ty=2005;to=08;td=31;th=24;tm=0;ts=0;
function e(){
ny=0;no=0;nd=0;nh=0;nm=0;ns=0;n=new Date();
if(n.getYear()>ty){t.s.value=0;t.m.value=0;t.h.value=0;t.d.value=0;t.o.value
=0;t.y.value=0;}
else{
ns=ns+ts-n.getSeconds();if(ns<0){ns=60+ns;nm=-1;}t.s.value=ns;
nm=nm+tm-n.getMinutes();if(nm<0){nm=60+nm;nh=-1;}t.m.value=nm;
nh=nh+th-n.getHours();if(nh<0){nh=24+nh;nd=-1;}t.h.value=nh;
nd=nd+td-n.getDate();if(nd<0){
x=n.getMonth();
if(x==0||x==2||x==4||x==6||x==7||x==9||x==11){nd=31+nd;}
if(x==3||x==5||x==8||x==10){nd=30+nd;}
if(x==1){if(n.getYear()/4-Math.floor(n.getYear()/4)==0){nd=29+nd;}else{nd=28
+nd;}}
}no=-1;t.d.value=nd;
no=no+to-n.getMonth();if(no<0){no=11+no;ny=-1;}t.o.value=no;
ny=ny+ty-n.getYear();if(ny<0){t.y.value=0;}else{t.y.value=ny;setTimeout("e()
",1000);}
}
}
</script>
Example:
http://members.cox.net/icystorm/retire
---------------
Joseph
(e-mail address removed)
(Please remove both occurrences of "nospam" to reply via email, or simply
reply here in USENET instead.)