...

View Full Version : Form Within Countdown Timer Javascript



adambazza
08-19-2004, 12:02 AM
Hello,

I have the following javascript:
<html>
<body>
<FORM name=count>
<INPUT size=73 name=count2>
</FORM>
</body>
</html>
<SCRIPT language="javascript">
var until = 'Event Title';
var current = 'A Title of some sort to display when time is up';
var montharray =
new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var theyear;
var themonth;
var theday;
var thehr;
var themin;
var thesec;
function countstart(yr, mth, day, hour, min, sec) {
theyear = yr;
themonth = mth;
theday = day;
thehr = hour;
themin = min;
thesec = sec;
setTimeout('countdown()', 1000);
}
function countdown() {
var today = new Date();
var todayy = today.getYear();
if (todayy < 1000) {
todayy += 1900;
}
var todaym = today.getMonth();
var todayd = today.getDate();
var todayh = today.getHours();
var todaymin = today.getMinutes();
var todaysec = today.getSeconds();
var todaystring =
montharray[todaym]
+ ' ' + todayd
+ ', ' + todayy
+ ' ' + todayh
+ ':' + todaymin
+ ':' + todaysec;
futurestring =
montharray[themonth-1]
+ ' ' + theday
+ ', ' + theyear
+ ' ' + thehr
+ ':' + themin
+ ':' + thesec;
dd = Date.parse(futurestring) - Date.parse(todaystring);
dday = Math.floor(dd/(60*60*1000*24)*1);
dhour = Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
dmin = Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
dsec= Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
if (dday == 0 &&
dhour == 0 &&
dmin == 0 &&
dsec == 0) {
document.forms.count.count2.value = current;
return;
} else {
document.forms.count.count2.value=
' '
+ dday + ' days, '
+ dhour + ' hours, '
+ dmin + ' minutes, and '
+ dsec + ' seconds left until '
+ until;
}
setTimeout('countdown()', 1000);
}
//enter the count down date using the format year/month/day/hour/minute/seconds
countstart(2004,3,29,1,0,0);
</SCRIPT>

But this gives a form in a long line in the format:
? days, ? hours, ? minutes, and ? seconds left until ?

What I am trying to get is it in the format:
? days, ? hours,
? minutes, and ? seconds
left until
event title

What do i need to change to accomplish this?

Cheers in advance.

Adam Bailey

Willy Duitt
08-19-2004, 07:41 AM
Change the form to a span and use innerHTML to write to the span contents....

It is only a few lines of code and if you edit your post to use
... CODE HERE... tags so that your script is not corrupted with broken lines.... You may get lucky and find someone will do this for you.... I was going to give it a quick shot but there is too many errors in your script as posted and you failed to provide a link to the original....

.....Willy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum