title: Submit form with Javascript throws TypeError
body: <p>I've got this really frustrating problem. I want to submit a form with Javascript and no matter what I try I always end up getting <code>Uncaught exception: TypeError: Cannot convert 'document.getElementById('loginForm')' to object</code>.</p>
  
  <p>I've been staring at this code for some time now and I really can't figure it out. I'm sure it's really simple, but I just can't see the solution.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;form method="post" action="do.php?a=signin" id="loginForm"&gt;
    &lt;input name="usr" class="test" placeholder="Användarnamn" type="text" /&gt;
    &lt;input name="pwd" class="test" placeholder="Lösenord" type="password" /&gt;
  &lt;/form&gt;
  
  &lt;span class="test"&gt;&lt;a href="fblogin.php"&gt;&lt;img src="gfx/ico/fb.jpg" alt="" /&gt; Logga in via Facebook&lt;/a&gt;&lt;/span&gt;
  &lt;span class="test"&gt;&lt;a href="javascript: doLogin();"&gt;&lt;img src="gfx/ico/Unlock.gif" alt="" /&gt; Logga in &amp;#0187;&lt;/a&gt;&lt;/span&gt;
  
  &lt;script type="text/javascript"&gt;
      function doLogin() {
          document.getElementById('loginForm').submit();
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>What am I missing!?</p>