title: Submitting textarea when clicked enter
body: <p>First of all, there are many answers for this type of questions but none of them work for me because I am using multiple forms.</p>
  
  <p>My question is, I need a script which will submit the data inside the textarea when clicked enter but the script must work with the code below. </p>
  
  <pre><code>&lt;?php
      $inputValue = NULL;
      $id = "[1,2,3];"
  
      if(isset($_POST['inputName'])){
          $inputValue = $_POST['inputName'];
          echo "&lt;br&gt;Input Value: " . $inputValue;
      }
  
      if(isset($_GET['id'])){
          $getValue = $_GET['id'];
          echo "&lt;br&gt;Get Value: " . $getValue;
      }
  ?&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Multiple Forms in One Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;br&gt;
          &lt;a href="index.php"&gt;Main Page&lt;/a&gt;
          &lt;br&gt;
          &lt;?php for($i = 0; $i &lt; 3; $i++){ ?&gt;
          &lt;form action="index.php?id=&lt;?php echo $id[$i] ?&gt;" method="post" name="formName"&gt;
              &lt;textarea name="inputName"&gt;&lt;/textarea&gt;
              &lt;input type="submit" name="submitName"&gt;
          &lt;/form&gt;
          &lt;?php } ?&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I used to use this one below, which doesn't work if there are multiple forms in one page. </p>
  
  <pre><code>&lt;script&gt;
      $(function() {
          $('textarea#inputName').on('keydown', function(e) {
              if(e.keyCode == 13 &amp;&amp; !e.shiftKey){
                  document.getElementById('formName').submit();
              }
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Just to make it clear, If I create a single form in a page (like subscription for newsletter of a site) the script above will work. But if you have more than 1 form in a page (like facebook's comment boxes right after every post) the script above will not work. Thank you.</p>