title: Uncaught TypeError: Cannot read property 'submit' of null when submitting a form
body: <p>I have a webpage in which I am trying to get an input and submit a form using that input. But the code below gives an error "Uncaught TypeError: Cannot read property 'submit' of null"</p>
  
  <pre><code>&lt;script&gt;
      function SetMissingDataReason1(){
          var reasons = prompt("Please enter a reason for missing data","Not collected");
          document.getElementById('reason1').value = reasons;
          document.getElementById('missingdataform1').submit();
      }
  &lt;/script&gt;
  &lt;form action='projectchecklist.php' method='post' id='missingdataform1'&gt;
  &lt;input type='hidden' name='action' value='setmissingdatareason'&gt;
  &lt;input type='hidden' name='projectid' value='124'&gt;
  &lt;input type='hidden' name='enrollmentid' value='22636'&gt;
  &lt;input type='hidden' name='projectchecklistid' value='9'&gt;
  &lt;input type='hidden' name='reason' id='reason1'&gt;
  &lt;/form&gt;
  &lt;a href='#' onClick='SetMissingDataReason1();'&gt;?&lt;/a&gt;
  </code></pre>
  
  <p>What am I missing here?</p>