Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Countdown code doesn't work

  1. #1
    Join Date
    Sep 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Countdown code doesn't work

    At the following site on this server http://www.dynamicdrive.com/dynamici...dhtmlcount.htm there is a count down code that I am trying to use on my website. It works once then doesn't work. Does it matter if the code is wrapped?

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    By working only "once", do you mean you have multiple copies of the same script on the page? Please elaborate.

  3. #3
    Join Date
    Sep 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I only have it on the page once. When I visit my site right after putting it on my page it works. When i work on my site it doesn't work.

  4. #4
    Join Date
    Sep 2004
    Location
    Indonesia
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What is Your site? Maybe we can see whats wrong by visiting it.

  5. #5
    Join Date
    Sep 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    www.simulationcity.bravehost.com

    I'm trying to use the code to countdown the release of RollerCoaster Tycoon3.

  6. #6
    Join Date
    Sep 2004
    Location
    Indonesia
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Don't put them all in one lline...

    Some parts of the script contains a "//" sign. It's a one line comment... It means that from that point on to the rest of the line is considered as a comment.

  7. #7
    Join Date
    Sep 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm not putting it one one line. My web hoster (Bravenet) squishes it all together.So there are no spaces in-between. The only way it would work was if I put it in my forum.

  8. #8
    Join Date
    Sep 2004
    Location
    Indonesia
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmmm... Try to put the script in an external file then...

    Cut the section betwen the <script> and </script> tags, and paste it in another a file, countdown.js for example.

    Modify the script tag to
    Code:
    <script src="countdown.js" language="JavaScript1.2">
    Will it work?

  9. #9
    Join Date
    Sep 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm just going to put it in my forum I don't understand what you're saying.

  10. #10
    Join Date
    Sep 2004
    Location
    Indonesia
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK.. first, copy this code
    Code:
    /*
    Dynamic countdown Script-  Dynamic Drive (www.dynamicdrive.com)
    For full source code, 100's more DHTML scripts, and TOS,
    visit http://www.dynamicdrive.com
    */
    
    
    function setcountdown(theyear,themonth,theday){
    yr=theyear;mo=themonth;da=theday
    }
    
    //////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////
    
    //STEP 1: Configure the countdown-to date, in the format year, month, day:
    setcountdown(2004,09,30)
    
    //STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
    var occasion="Christmas!"
    var message_on_occasion="Merry Christmas!"
    
    //STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
    var countdownwidth='480px'
    var countdownheight='20px'
    var countdownbgcolor='lightblue'
    var opentags='<font face="Verdana"><small>'
    var closetags='</small></font>'
    
    //////////DO NOT EDIT PASS THIS LINE//////////////////
    
    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
    var crosscount=''
    
    function start_countdown(){
    if (document.layers)
    document.countdownnsmain.visibility="show"
    else if (document.all||document.getElementById)
    crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
    countdown()
    }
    
    if (document.all||document.getElementById)
    document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')
    
    window.onload=start_countdown
    
    
    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[mo-1]+" "+da+", "+yr
    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 on day of occasion
    if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+message_on_occasion+closetags
    return
    }
    //if passed day of occasion
    else if (dday<=-1){
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
    return
    }
    //else, if not yet
    else{
    if (document.layers){
    document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
    document.countdownnsmain.document.countdownnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
    }
    setTimeout("countdown()",1000)
    }
    Save it as "countdown.js" and upload it to Your server. Put it in the same directory as Your forum page.

    And then add this code :
    Code:
    <script src="countdown.js" language="JavaScript1.2"></script>
    <ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>
    on Your forum page...

    No guarantees it'll work though

Bookmarks

Posting Permissions

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