EasyBB EasyBB - 1 year ago 433
Javascript Question

submit two forms with one submit button jQuery

I have tried multiple ways of doing this, by searching on stackoverflow for the answer.

I have two forms

Form 1 basic setup:

<form action="/post" class="frm-form" method="post" name="post"
onsubmit="return vB_Editior['text_editor'].prepare_submit(0,0)" id="quick_reply">
<input type="submit" name="post" value="Send">

Form 2 basic setup:

<form enctype="multipart/form-data" id="tagnotif" style="display:none;"
onsubmit="return vB_Editor['text_editor'].prepare_submit(0,0)" name="post2"
method="post" action="/privmsg">
<input id="username" class="post" type="text" tabindex="1" size="25"
name="username[]"style="margin:1px 0"><br />
<input id="acpro_inp10" class="post" type="text"
onkeypress="if (event.keyCode==13){return false}" title="" tabindex="2"
maxlength="64" size="45" value="You have been tagged" name="subject"><br />
<textarea id="textingnotification" rows="15" cols="9"
name="message" tabindex="3"></textarea>
<input type="hidden" value="" name="lt">
<input type="hidden" value="inbox" name="folder">
<input type="hidden" value="post" name="mode">

I just need these two forms to be submitted on SEND press of first form

TRIED USING THIS CODE VARIABLES WITH THE MAIN SCRIPT: Though it won't pass both, and it won't refresh the page...

$(document).ready(function() {
$('#quick_reply').ajaxForm(function() {
alert("Thank you for your submitting form 1");
$('#tagnotif').ajaxForm(function() {
alert("Thank you for your submitting form 2");


function mySubmitFunction() {


I don't think you can do two regular post requests from a single html page, because making the post involves leaving the page and following the redirect response.

If you're submitting the forms via ajax, why not just make a single ajax button and grab the needed parameters to stick in the request? IE:

  type: 'POST',
  dataType: 'JSON',
  data: {param1: $('input#param1').val(), param2: $('input#param2').val()},
  url: 'url to post to',
  success: (your success callback function goes here)