0

I need to load 2 actions with 1 button. The first action uploads a file to the server and the second action loads some customer data.

HTML

<p class="text-center font-big"><u>Load Photometric Data (.ies File)</u></p>

<form id= "form1" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>"     enctype="multipart/form-data">
<input type="file" name="file" id="file">
<input type="hidden" name="upload_file" />
</form>

<form id= "form2" method="post" action="/roadlite_main.php">                        
<input type="hidden" name="new_data" />                     
</form>

<input type="button" value="Click Me!" onclick="submitForms()" />

js

<script language="javascript">
submitForms = function()
{
document.getElementById("form1").submit();
document.getElementById("form2").submit();
}
</script>

The second form (or maybe the last) always loads OK ... the first form fails to load and does not upload the file.

Any ideas!

Ozzie
  • 21
  • 3
  • Check this link: https://stackoverflow.com/questions/7843355/submit-two-forms-with-one-button You cannot simply submit two forms one by one as it will affect propagation. Either submit one by ajax and other by form post or try waiting for submit of first and then post second. Check answers in the above link post. Thanks – Jitender Dhaliwal Jul 20 '21 at 05:40
  • Note that the accepted answer in that link is wrong. The others look okay though. Basically: use AJAX or just lump the two forms together. – Joel Rummel Jul 20 '21 at 05:51

0 Answers0