Web Analytics Made Easy -
StatCounter jQuery Callback Function Timer - CodingForum

Announcement

Collapse
No announcement yet.

jQuery Callback Function Timer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • jQuery Callback Function Timer

    I want to create a function in jQuery that is a continous timer that calls itself every second:

    I'm getting an error undefined values:

    Code:
    var curloc=window.location.href;
    var tcorner="gtype=T";
    curpos=curloc.indexOf(tcorner);
    // teachers corner clock
    if (curloc.indexOf("gtype=T")>-1){
    h=0;
    m=0;
    s=0;
    window.setInterval(function(h,m,s) {
    //temptime=startclock(h,m,s).split("_");
    //h=temptime[0];
    //m=temptime[1];
    //s=temptime[2];
    
    s=s+1;
    if (s==60){
    s=0;
    m=m+1;
    }
    
    if (m==60){
    m=0;
    h=h+1;
    }
    else{
    h=h;
    }
    
    // leading zero
    ds=s;
    if (s<10) {ds="0" + s;}
    
    dm=m;
    
    if (h==0){
    dh="";
    }
    else{
    dh=h;
    }
    
    $(".visibleDiv").html(dh+" "+dm+":"+ds); 
    }, 1000);
    
    }
    Last edited by mathceleb; Aug 27, 2011, 04:27 PM.

  • #2
    I was able to get this to work calling an external function.

    However, if there is a way to do it within itself passing the values to itself, I'd like to know.

    Comment

    Working...
    X