1

This is a form in one HTML document:

<form action="" method="post" name="f1">
//Checkboxes, buttons, ....
<button onclick="submitForms()"/>Submit</button>
</form>
//Other stuff
<?php include 'another.html'; ?>

In another.html,

//Other stuff
<form action="" method="post" name="f2">
//Checkboxes
</form>
//Other

Can I submit both forms with the single submit?

This does not work:

submitForms = function(){
document.forms["f1"].submit();
document.forms["f2"].submit();}
  • 3
    you need to understand what a form submit does in order to understand why this wont work – Jaromanda X Aug 07 '16 at 10:03
  • I entered wrongly, it should be a button not submit. Is it possible for the javascript to work on two html documents? – user6571534 Aug 07 '16 at 10:09
  • 2
    well, that makes a lot of difference then .... you need to understand what a `form.submit();` does in order to understand why this wont work – Jaromanda X Aug 07 '16 at 10:10
  • @user6571534 I guess you haven't got it. So... a form submit triggers a page navigation. once you submit....well thats it.... you go to the page. I think what you are look into is a AJAX or asynchronous submit. and also look into this question: http://stackoverflow.com/questions/7843355/submit-two-forms-with-one-button – Iceman Aug 07 '16 at 10:24
  • also the answer below by @Pikachu is a direct copy of the accepted answer from above link – Iceman Aug 07 '16 at 10:28

0 Answers0