Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

CountDown/Timer Script DRIVING ME CRAZY!

count down countdown timer

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 Tommyscriptsall

Tommyscriptsall

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 05 September 2015 - 08:07 PM

So, I am a Pretty seasoned Novice at scripting and coding. How ever I have developed some health issues and have forgotten ALOT! I have been working on a website (taking my time).....  One of the main factors on my website depend on timers/countdowns... I am going with HTML5 and JS. Below is the part I am having probs with, I know it is correct, but for some reason it is not. I have been spending days trying to finger it out. NO LUCK!  Any Help would be greatly appreciated.

 

function ShowTimes() 
{
var now = new Date();
  var hrs = 20-now.getHours();
  var mins = 59-now.getMinutes();
  var secs = 59-now.getSeconds();
  var str = '';
 
----------------------------------------below is where the prob comes in, seems to be breaking the script..
 
 if(secs == 0){
if(mins == 0){
timeField.innerHTML = 'Time's up!';
clearInterval(timer);
                                        alert('Time's up');
return;
 
------------------------------------------------------------------------------------------------------------------
     
      str += '<br>'+hrs+' hours '+mins+' minutes '+secs+' seconds';
             document.getElementById('countdown').innerHTML = str;
            document.getElementById("hrs").innerHTML = ("0"+hrs).slice(-2);
            document.getElementById("mins").innerHTML = ("0"+mins).slice(-2);
            document.getElementById("secs").innerHTML = ("0"+secs).slice(-2);
 
 
 
     };
 
I have tried every thing possible to no avail.. Am I missing a { } or ; or what?


#2 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts

Posted 08 September 2015 - 06:26 AM

This looks like a code fragment, not the full JS code.

 

if this is a code fragment, the only way to figure out your problem is to have the whole thing, or put it in a fiddle (http://jsfiddle.net)


My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download