PDA

View Full Version : Need Countdown help


bk4_BJ
05-01-2003, 04:51 PM
i need to get this countdown not to show up in a text box. At the bottom of the script there is a section that makes it show up in a text box, and i need to figure out how to get it out of that. There are also some unkown variables that im not sure what they do yet. Ive been working on this for about 4 days and really need to get this finished soon.


speed=1000;
len=40;
tid = 0;
num=0;
clockA = new Array();
timeA = new Array();
formatA = new Array();
dd = new Date();
var d,x;

function doDate(x)
{
for (i=0;i<num;i++) {
dt = new Date();

if (timeA[i] != 0) {
v1 = Math.round(( timeA[i] - dt )/1000) ;
if (v1 < 0)
clockA[i].date.value = "**BANG!**";
if (formatA[i] == 1)
clockA[i].date.value = v1;
else if (formatA[i] ==2) {

v1 = Math.floor( v1/60);
min = v1 %60 ;
hour = Math.floor(v1 / 60);
if (min < 10 ) min = "0"+min;
clockA[i].date.value = hour+" h "+min+" m ";
}
else if (formatA[i] ==3) {

v1 = Math.floor( v1/60);
min = v1 %60 ;
v1 = Math.floor(v1 / 60);
hour = v1 %24 ;
day = Math.floor(v1 / 24);
if (min < 10 ) min = "0"+min;
if (hour < 10 ) hour = "0"+hour;
clockA[i].date.value = day+" d "+hour+" h "+min+" m ";
}
else if (formatA[i] ==4 ) {
v1 = Math.floor( v1/60);
min = v1 %60 ;
v1 = Math.floor(v1 / 60);
hour = v1 %24 ;
day = Math.floor(v1 / 24);
clockA[i].date.value = day+(day==1?" day ":" days ")+hour+(hour==1?" hour ":" hours ")+min+(min==1?" min ":" mins ")
}
else
clockA[i].date.value = "Invalid Format spec";
}
else
clockA[i].date.value = "Countdown till when?";
}

tid=window.setTimeout("doDate()",speed);
}

function start(d,x,format) {
clockA[num] = x
timeA[num] = new Date(d);
formatA[num] = format;
//window.alert(timeA[num]+":"+d);
if (num == 0)
tid=window.setTimeout("doDate()",speed);
num++;
}

//this is the section that i was talking about below:thumbsup:
// \/ \/
function CountdownLong(t,format,len)
{
document.write('<font size="+1"><center>')
document.write('<FORM name=form'+num+'><input name=date size=')
document.write(len)
document.write(' value="Requires Javascript"></FORM>')
document.write('</font></center>')
start(t,document.forms["form"+num],format);

}

function Countdown2001seconds()
{
CountdownLong("May 19, 2003 16:00",1,8);
}

function Countdown2001()
{
CountdownLong("May 19, 2003 16:00",4,30);
}

function Countdown(t)
{
CountdownLong(t,4,30);
}

// end-->

//this is in the body, not in javascript
// \/ \/
<td colspan=4 height="69" valign="middle" bgcolor="black" align="center"> <div align="left"><font face="Arial, Helvetica, sans-serif"><script language="javascript">Countdown("May 18, 2003 20:00");
</script></font></div></td>


i just need to figure out the var's that i need to make the date show up before i can write it, and i havent been able to yet :(

bk4_BJ
05-02-2003, 04:33 PM
:confused: :confused: :confused:

someone please help i really need to figure this out....
I need to know how to get the countdown out of the text box. I am totally lost in this matter. I see something about the form, but when i took that out, it gave me an error. Then i tried to make another function with the same parameters and same everything but w/o the form, it still gave me errors. help:rolleyes:
:( :confused: :confused: :confused:

beetle
05-02-2003, 04:59 PM
You can use mine -- but it doesn't work in IE 5.0

http://www.peterbailey.net/dhtml/datestamp.htm