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;t d=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.v alue=0;t.o.valu e
=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.g etYear()/4-Math.floor(n.ge tYear()/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.va lue=ny;setTimeo ut("e()
",1000);}
}
}
</script>
Example:
---------------
Joseph
icynospamstorm@ hotnospammail.c om
(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;t d=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.v alue=0;t.o.valu e
=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.g etYear()/4-Math.floor(n.ge tYear()/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.va lue=ny;setTimeo ut("e()
",1000);}
}
}
</script>
Example:
---------------
Joseph
icynospamstorm@ hotnospammail.c om
(Please remove both occurrences of "nospam" to reply via email, or simply
reply here in USENET instead.)
Comment