Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have multiple submit buttons, the way you can tell is by giving each of them a unique name attribute, like this:</p> <pre><code>&lt;input type="submit" name="submit1" value="Submit 1"/&gt; &lt;input type="submit" name="submit2" value="Submit 2"/&gt; &lt;input type="submit" name="submit3" value="Submit 3"/&gt; </code></pre> <p>The one that is focused is sent along with the form submit, so if you clicked the one with a name of "submit2", that would come through in the form POST (or GET). If enter is hit, the first button in the source (in this case submit1) is considered the default and is sent along. You could set it to display:none to use as a dummy for detecting whether enter was pressed vs actually clicking a submit button.</p> <p><em><strong>EDIT:</em></strong></p> <p>In response to your comments, to capture the enter key getting pressed in certain elements you can do this with jQuery.</p> <p>Note, you'll need to give first_name and add_item id attributes, and turn add_item into a type="button" instead of type="submit".</p> <p>HTML:</p> <pre><code>&lt;form action="" method="POST"&gt; &lt;input type="text" name="first_name"/&gt; &lt;input type="text" id="item" name="item"/&gt; &lt;input type="button" id="add_item" value="Add item"/&gt; &lt;input type="submit" value="Submit"/&gt; &lt;/form&gt; </code></pre> <p>JS:</p> <pre><code>$("#item").keydown(function(event){ if(event.keyCode == 13) { addFields(); event.preventDefault(); event.stopPropagation(); } }); $("#add_item").click(function(event) { addFields(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload