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
    Sep 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Mutiple Countdowns

    Hi, I'm sorry you guys but I have no idea what I'm doing. I'm using this script below. It countsdown to dates. What I want is to have more then one of theses on a webpage at the same time (counting down to differnet days). I don't know what I have to edit to get more then one to work. I read the thing on how to edit it for mutiples. But I can't figure it out. I also tried some things of my own. I really need some help please. Any Ideas? I have no idea what i'm doing. Help? Here's the script:
    -----------------------------------------------------------------------------------



    <script language="JavaScript1.2">

    /*
    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(2003,11,27)

    //STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
    var occasion="Thanksgiving."
    var message_on_occasion="Happy Thanksgiving"

    //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+closeta gs)
    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)
    }
    </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>

    -----------------------------------------------------------------------------------
    So what would I need to edit to get mutiple scripts working on the same page? Thanks for the help.
    - Danny

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Firstly; This probably should have been posted in the Dynamic Drive Forum.

    Secondly; I tried to paste your code into a tester but it threw more errors than I cared to try to fix. (most likely from multiple cc&p)

    Lastly; I found this nice short script written by: Stevie Peele
    in the Post a Javascript Forum that should not be difficult to
    place multiple times on a page.

    <script type="text/javascript">
    var now = new Date();
    var then = new Date("December 25,2003");
    var gap = then.getTime() - now.getTime();
    gap = Math.floor(gap / (1000 * 60 * 60 * 24));
    document.write("Only " + gap + " more days until Christmas");
    </script>


    ......Willy
    Last edited by Willy Duitt; 09-29-2003 at 06:43 AM.


  •  

    Posting Permissions

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