Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML form with two submit buttons and two different actions
    primarykey
    data
    text
    <p>I have this form, with 2 submit buttons:</p> <pre><code>&lt;form method="post" onsubmit="send_mail(this);return false"&gt; &lt;select name="liste"&gt; &lt;option value='0'&gt;Choose list&lt;/option&gt; &lt;option value="1"&gt;list1&lt;/options&gt; &lt;option value="2"&gt;list2&lt;/options&gt; &lt;/select&gt; &lt;p&gt;Subject: &lt;input type="text" name="subject" /&gt;&lt;br /&gt; &lt;div id="editor"&gt; &lt;textarea value="editor1" name="editor1"&gt;Some text here&lt;/textarea&gt; &lt;/div&gt; &lt;input type="submit" value="Sent Mail!" /&gt; &lt;div id="testmail"&gt; &lt;p&gt;&lt;input type="button" onsubmit="send_Testmail(this);return false" value="Sent Test" /&gt; To: &lt;input type="text" name="testemail" /&gt;&lt;br /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>On the form, as you can see, it has this javascript function: <code>onsubmit="send_mail(this);return false</code></p> <p>Which looks like this:</p> <pre><code>function send_mail(form) { jQuery.post('editor.php', jQuery(form).serialize(), function(data) { jQuery('#center').html(data); }); } </code></pre> <p>The script sends the form data to my editor.php script, which processes and send the mail, and then returns "email send". The scripts replaces the <code>&lt;div&gt;</code> with the <code>&lt;form&gt;</code>, with this <code>return</code> statement. This is working as I wanted it to.</p> <p>Now I want to create another button and input textbox to let the user type in an email and send a test of the above form, before submitting it. </p> <p>How can I do this? The problem is that the 2 button always submits the javascript send_mail, since its attached to the form tag <code>onsubmit</code>. </p> <p>This is probably a basic question - I hope someone can point me in the right direction.</p> <p><strong>EDIT/UPDATE:</strong></p> <p>To clarify: The first button should send $post to my editor.php file and the javascript replaces the div that holds the entire form. My Second button should send $post to my testmail.php file and only replace the div that holds this button and input textfield (the with ID "testmail". </p> <p>Hope that makes sense.. and thanks a lot for the help so fare.</p>
    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.
 

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