setTimeout call in javascript class recursively
<p>I have these lines of code in my program. I want to implement setTimeout in a javascript class. I tried storing "this" but seems didn't work out for me.
In this class logic is if input is 0, then it will show output 0, but if input is 1 it will start a timer which is already specified and after that timer finishes it will give output its a ondelay timer.</p>

<pre><code>ONDClass = function(){
    this.id;
    this.input;
    this.source;
    this.target;
    this.timer;
        var timerValue;
        this.TimerID;
        this.TotalSeconds;
        var thisObj = this;
        var c = 0;
        this.setID = function(id){
              this.id = id;
              timerValue = this.id + "C";
        }

        this.getID = function(){
              return this.id;
        }

        this.setTimer = function(timer){
              this.timer = timer
        }

        this.getTimer = function(timer){
              return this.timer;
        }

    this.UIelementTaget = function(target){
        this.target = target;
    }

        this.UIelementSource = function(source){
        this.source = source;
    }

    this.setInput = function(input){
        this.input = input;
    }

    this.getInput = function(){
        return this.input
    }

        this.UpdateTimer = function(){
            console.log(c);
            document.getElementById(timerValue).innerHTML = c;
        }

        this.createTimer = function(timerValue,time){
              this.TimerID = document.getElementById(timerValue);
              this.TotalSeconds = time;
             // this.UpdateTimer();

              setTimeout(function() { 
                    document.getElementById(timerValue).innerHTML = c;
                    console.log(c);
                    thisObj.Tick();
              }, 1000)
        }

        this.Tick = function(){
              c++
              //this.UpdateTimer();

              if(c &lt; this.TotalSeconds){
                    setTimeout(function() { 
                                document.getElementById(timerValue).innerHTML = c;
                                console.log(c);
                                thisObj.Tick();
                          }, 1000)
              } else {
                    return this.input;
              }
        }


        this.getOutput = function(){
              if(this.input == 0){
                    var htmltimer = "&lt;div id = " + timerValue + " class = 'timerValue'&gt;" + this.getTimer() + "&lt;/div&gt;";
                    $("#" + this.id).append(htmltimer);
                    return this.input;
              } else {
                    var htmltimer = "&lt;div id = " + timerValue + " class = 'timerValue'&gt;&lt;/div&gt;";
                    $("#" + this.id).append(htmltimer);
                    this.createTimer(timerValue,this.getTimer());
                    return this.input;
              }
    }

       this.getUISourceElement = function(){
              if(this.source == undefined)
                   return false;
              else
                    return true;
        }

        this.addExtraDiv = function(){
        var divinput = this.id +"I";
              var divoutput = this.id +"O";
              var htmlinput = "&lt;div id = " + divinput + " class = 'inputBoxTimer'&gt;" + this.getInput()+ "&lt;/div&gt;";
              var htmloutput = "&lt;div id = '" + divoutput + "' class = 'outputBoxTimer'&gt;" + this.getOutput() + "&lt;/div&gt;";
              $("#" + this.id).append(htmloutput);
              $("#" + this.id).append(htmlinput);

        }
}
</code></pre>

<p>The problem is with the setTimeout function. It's not calling every time and it's giving me same output weather its 1 or 0</p>
