Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>First Suggestion:</strong></p> <p>Create a Javascript Variable that will reference the button clicked. Lets call it <em>buttonIndex</em></p> <pre><code>&lt;input type="submit" onclick="buttonIndex=0;" name="save" value="Save" /&gt; &lt;input type="submit" onclick="buttonIndex=1;" name="saveAndAdd" value="Save and add another" /&gt; </code></pre> <p>Now, you can access that value. 0 means the save button was clicked, 1 means the saveAndAdd Button was clicked.</p> <p><strong>Second Suggestion</strong></p> <p>The way I would handle this is to create two JS functions that handle each of the two buttons.</p> <p>First, make sure your form has a valid ID. For this example, I'll say the ID is "myForm"</p> <p><strong>change</strong></p> <pre><code>&lt;input type="submit" name="save" value="Save" /&gt; &lt;input type="submit" name="saveAndAdd" value="Save and add another" /&gt; </code></pre> <p><strong>to</strong></p> <pre><code>&lt;input type="submit" onclick="submitFunc();return(false);" name="save" value="Save" /&gt; &lt;input type="submit" onclick="submitAndAddFunc();return(false);" name="saveAndAdd" value="Save and add </code></pre> <p>the return(false) will prevent your form submission from actually processing, and call your custom functions, where you can submit the form later on.</p> <p><strong>Then your functions will work something like this...</strong></p> <pre><code>function submitFunc(){ // Do some asyncrhnous stuff, that will later on submit the form if (okToSubmit) { document.getElementById('myForm').submit(); } } function submitAndAddFunc(){ // Do some asyncrhnous stuff, that will later on submit the form if (okToSubmit) { document.getElementById('myForm').submit(); } } </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. 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