title: Javascript countdown and countup timer based on user input
body: <p>I'm new to Javascript and was playing around a bit with timers. I found code for a countdown timer based on test field input <a href="http://www.dynamicdrive.com/forums/showthread.php?67631-Timer-with-an-input-text-box" rel="nofollow">here</a>, and I tried adding a countup timer to the same page, but it's not working. </p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;div id="countdown"&gt;&lt;/div&gt;
  &lt;div id="countup"&gt;&lt;/div&gt;
  &lt;div id="notifier"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
  function startTimer() {
    userInput = document.getElementById('userTime').value;
      if(userInput.length == 0){
          alert("Please enter a value");
      } else {
      var numericExpression = /^[0-9]+$/;
      if(!userInput.match(numericExpression)){
        alert("Please enter a number")
      } else {
        var countuptime = 0;
        function display( notifier, str ) {
            document.getElementById(notifier).innerHTML = str;
        }
  
        function toMinuteAndSecond( x ) {
          return Math.floor(x/60) + ":" + x%60;
        }
  
        function setTimer( remain, actions, countuptime ) {
            (function countup() {
                display("countup", toMinuteAndSecond(userInput - countuptime));
                (countuptime+= 1) &lt;= userInput &amp;&amp; setTimeout(arguments.callee, 1000);
             })();
             (function countdown() {
                 display("countdown", toMinuteAndSecond(remain));
                 actions[remain] &amp;&amp; actions[remain]();
                 (remain -= 1) &gt;= 0 &amp;&amp; setTimeout(arguments.callee, 1000);
              })();
        }
  
        setTimer(userInput, {
           10: function () { display("notifier", "Just 10 seconds to go"); },
            5: function () { display("notifier", "5 seconds left");        },
            0: function () { display("notifier", "Time is up");       }
        });
      }
    }
  }
  &lt;/script&gt;
  Please Enter A Number: &lt;input type="text" id="userTime" /&gt;
  &lt;input type="button" value="Go" onclick="startTimer()" /&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>Basically, I tried creating a new variable (countuptime) that starts at 0 and goes up until it's is the same as userInput, at which point it should stop. However, when I try to test, the count up timer displays NaN:NaN. I'm trying to stay away from JQuery right now and get the basics of Javascript.</p>