title: getElementById and multiple forms
body: <p>I am having this situation with many forms (for instance I show you a coupe of them):</p>
  
  <pre><code>&lt;form method="POST" enctype="multipart/form-data"&gt;  
  &lt;textarea name="content" id="content" class="form-control" required=""&gt;&lt;/textarea&gt;
     &lt;input name="code" id="code" type="hidden" value="1180224194"&gt;
     &lt;input name="postId" id="postId" type="hidden" value="167"&gt;  
     &lt;button class="btn btn-commenta"&gt;Say something&lt;/button&gt;
  &lt;/form&gt;
  &lt;form method="POST" enctype="multipart/form-data"&gt;
     &lt;textarea name="content" id="content" class="form-control" required=""&gt;&lt;/textarea&gt;
     &lt;input name="code" id="code" type="hidden" value="95959622661"&gt;
     &lt;input name="postId" id="postId" type="hidden" value="144"&gt;  
     &lt;button class="btn btn-commenta"&gt;Say something&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And I have some javascript like this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     $("form").submit(function (e) {
          e.preventDefault();
          var comment = document.getElementById("content").value;
          var postId = document.getElementById("postId").value;
          var code = document.getElementById("code").value;
          if(comment &amp;&amp; postId &amp;&amp; code){
          $.ajax({
            type: 'POST',
            ...SOME AJAX
          });
          }
          else {
              console.log("error");
              console.log(comment);
              console.log(postId);
              console.log(code);
          }
          return false;
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Everything works fine when I have a single form (or when I use the first one), but when I try to get the values of the inputs in a different form than the first one, I get an error and my fields are empty.</p>
  
  <p>How can I tell the script to select the values (with <code>getElementById</code>) of the submitted form? I tried with "this" but the console tells me "Cannot read property '<code>getElementById</code>' of <code>undefined</code>".</p>