title: Auto submit form using timer
body: <p>I wrote the following code. With this code pushing Submit button submits the form manually. I have also a timer which I want to auto submit the form after 10 seconds. But it does not work. It counts until 0 and then it does not do anything. Can you please tell me what I am missing or how to change my timer (if there, is the problem)? But I want the user to watch the timer as my example</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
  &lt;script type="text/javascript"&gt;
      function countDown(secs,elem)
      {
          var element = document.getElementById(elem);
          element.innerHTML = "&lt;h2&gt;You have &lt;b&gt;"+secs+"&lt;/b&gt; seconds to answer the questions&lt;/h2&gt;";
          if(secs &lt; 1){
          clearTimeout(timer);
          document.getElementById('myquiz').submit();
          }
          secs--;
          var timer = setTimeout ('countDown('+secs+',"'+elem+'")',1500);
      }
  &lt;/script&gt; 
  &lt;div id="status"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;countDown(5,"status");&lt;/script&gt;
   &lt;title&gt;Questionnaire&lt;/title&gt;
  &lt;style type="text/css"&gt; 
      span {color: #FF00CC}
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Please complete the following Survey&lt;/h1&gt;
  &lt;form name="quiz" id ="myquiz" method="post" action="includes/process.php"&gt;
  First Name: &lt;input type="text" name="firstname" id="fname"/&gt;
  &lt;p&gt;&lt;/p&gt;
  Last Name: &lt;input type="text" name="lastname" id="lname"/&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;input type="submit" name="submit" value="Go"&gt;&lt;/input&gt;
  &lt;input type="reset" value="clear all"&gt;&lt;/input&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>