www.webdeveloper.com
Results 1 to 2 of 2

Thread: Countdown timer

  1. #1
    Join Date
    May 2013
    Posts
    1

    Countdown timer

    i try to make a countdown timer from two different times.

    Code:
    if (oldcolorvar !== newcolor) {	
    			if (objtimer[0] < 1) {
    				objtimer[0] = new Date().getTime() + 96000;
    			}
    		      oldcolor[0] = newcolor;
    		     
    		      time = objtimer[0] - new Date().getTime();
    		      timeseconds = time / 1000;
    		      return timeseconds;
    		}
    		       console.log(objtimer[0]);
    		       time = objtimer[0] - new Date().getTime();
    		       timeseconds = time / 1000;
    		       return timeseconds;
    but objtimer is always undefined.

    I load the variables on index.html :

    var objtimer = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0]

    When i do console.log(objtimer[0]); before the IF it gives me the value. si it hink i do something wrong with

    objtimer[0] = new Date().getTime() + 96000;


    Any help is appreciated.

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,656
    was objtimer defined somewhere before this line?

    Code:
    if (objtimer[0] < 1) {

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles