Hi! I've been staring at this code for a week now, trying to figure out my bug! It is drivign me up the wall!!The codeis for a javascript countdown of 3 minutes. It pulls the start time from a database using coldfusion. I can get it to display 3 minutes but can't get it to count down! Some new eyes and some help will be greatly appreciated
Code:<cfquery name="GetStartDate" datasource="#ffldsn#"> Select PropValue From ffl_prop where propname='StartDraftTime' and Leagueid = #LeagueValue# </cfquery> <cfset DraftTickerTime = ParseDateTime("#GetStartDate.PropValue#")> <cfset DraftTickerTime2 = DateAdd("n",3,"#DraftTickerTime#")> <cfoutput> var yr=#dateFormat(DraftTickerTime2,"yyyy")#; var mo=#dateFormat(DraftTickerTime2,"m")#; var da=#dateFormat(DraftTickerTime2,"d")#; var ho=#TimeFormat(DraftTickerTime2,"H")#; var mi=#TimeFormat(DraftTickerTime2,"m")#; var sec=#TimeFormat(DraftTickerTime2,"s")#; var todaym = #dateFormat(DraftTickerTime,"m")#; var todayd = #dateFormat(DraftTickerTime,"d")#; var todayh = #dateFormat(DraftTickerTime,"d")#; var todaymin = #TimeFormat(DraftTickerTime,"m")#; var todaysec = #TimeFormat(DraftTickerTime,"s")#; var todayy = #Dateformat(Drafttickertime,"yyyy")#; </cfoutput> function countdown() { var today = new Date(); if(todayy < 1000) { todayy += 1900; } var todaystring = todaym+"/"+todayd+"/"+todayy+" "+todayh+":"+todaymin+":"+todaysec; futurestring = (mo-1+1)+"/"+da+"/"+yr+" "+ho+":"+mi+":"+sec; 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(document.getElementById) { if(dsec <= 0 && dmin <= 0 && dday <= 0) { //When countdown ends!! var countdownDiv = document.getElementById("countdown"); countdownDiv.innerHTML = "<b><div class='small'><font color='red'>Times Up!<BR>Please Draft</font></div></b><br>" + futurestring + "<br>" + todaystring; } else if(dmin > 6) { //When countdown ends!! var countdownDiv = document.getElementById("countdown"); countdownDiv.innerHTML = "<b><div class='small'><font color='red'>Times Up!<BR>Please Draft</font></div></b><br>" + futurestring + todaystring ; } //if on day of occasion else if(todayy == yr && todaym == mo && todayd == da) { // need to handle this!! var countdownDiv = document.getElementById("countdown"); countdownDiv.innerHTML = "<b>" + dmin + "</b> m <b>" + dsec + "</b> s hee"; setTimeout("countdown()",1000) } //else, if not yet else { var countdownDiv = document.getElementById("countdown"); countdownDiv.innerHTML = "<b>nothing</b>"; } } } if(document.getElementById) { document.write("<div id=countdown></div>"); document.write("<br>"); countdown(); } else { document.write("<br>"); document.write("<div></div>"); document.write("<br>"); }



The codeis for a javascript countdown of 3 minutes. It pulls the start time from a database using coldfusion. I can get it to display 3 minutes but can't get it to count down! Some new eyes and some help will be greatly appreciated


Bookmarks