title: input type="hidden" cannot be obtained from getElementById
body: <p>A call to <code>getElementById()</code> to retrieve a 'hidden' field on a form is returning <code>null</code>.</p>
  
  <p>I've studied other SO questions and many were using the hidden field's 'name' instead of 'id' in the call to <code>getElementById()</code> or were executing <code>getElementById()</code> in a script at top-of-file before the actual html containing the hidden field had been processed by the browser.  Both of those errors would explain why <code>getElementById()</code> was returning <code>null</code> for them.</p>
  
  <p>I could be wrong but I don't think that's my case here.</p>
  
  <p>This is my form:</p>
  
  <pre><code>  &lt;form name="theDeleteItemForm" id="deleteItemForm" action="deleteTheSelectedItem" 
               method="post"
      &lt;input type="hidden" id="theHiddenField" name="deleteThisSelectedItem" value=""&gt;
   &lt;/form&gt; 
  </code></pre>
  
  <p>And here is a Javscript handler that is <em>successfully</em> executing when a 'delete' button on the page is clicked (I can tell because my <code>alert()</code> boxes in the handler function below are popping up):</p>
  
  <pre><code>function deleteItem()
  {
      alert("Just entered deleteItem()");
  
      var theFieldToDelete = document.getElementById('theHiddenField');
  
       // THIS IS THE PLACE WHERE I FOUND THAT 'theFieldToDelete' WAS 'null'
      alert("Just got the hidden field element, which is: " +  theFieldToDelete );
  
        // THIS DOES NOTHING MORE THAN TO PREVENT THE 'alert' THAT FOLLOWS FROM APPEARING
      theFieldToDelete.value = "upForDeletion";
  
      alert("deleteItem() was called, about to submit the form");
  
      document.theDeleteItemForm.submit();    
  }
  </code></pre>
  
  <p>I'm not understanding why I get the <code>null</code> return from <code>getElementById()</code>.   I'm under the impression that
  <code>getElementById()</code> works FINE for <code>type="hidden"</code> fields.</p>
  
  <p>Furthermore, the id I used for my hidden field -- <code>theHiddenField</code>  -- is 100% unique in my file.</p>
  
  <p>Why am I getting <code>null</code> when I try to get the hidden field via <code>getElementById()</code> ?</p>