You have some problems
input type = image is a submit button, so you are trying to send something from a non-existent form, probably on the same page you are on
when you submit form1, it replaces the current page, if you manage to submit form2, this VERY can prevent sending form1
Here is what you can try (plain javascript):
<script language="javascript"> function() submitForms{ document.getElementById("firstform").submit(); document.getElementById("secondform").submit(); } </script> <form id="firstform" target="iframe1"> </form><iframe name="iframe1" style="display:none"></iframe> <form id="secondform" target="iframe2"> </form><iframe name="iframe1" style="display:none"></iframe> <button onclick="submitForms()"><img src="images/order-button.png" "/></button>
As an alternative to AJAX forms one at a time (assuming jQuery is loaded)
DEMO HERE
$(document).ready(function() { $("#subbut").click(function(e) { e.preventDefault(); // or make the button type=button $.post($("#firstform").attr("action"), $("#firstform").serialize(), function() { $.post($("#secondform").attr("action"), $("#secondform").serialize(), function() { alert('Both forms submitted'); }); }); }); });
UPDATE: If you want two form contents to be submitted in one action, just add serialization:
$(document).ready(function() { $("#subbut").click(function(e) { e.preventDefault(); // or make the button type=button $.post($("#firstform").attr("action"), $("#firstform").serialize()+$("#secondform").serialize(), function() { alert('Both forms submitted'); }); }); });
PS: PHP in the demo just repeats what you publish. No special action is required on the server.
source share