Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Within Countdown Timer Javascript

    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

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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] ... CODE HERE... [/code] 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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •