Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1917
  • Last Modified:

Submit one form one button to two different action file ?

I have a sample form per say myform, when I slick submit button I want the file be process by two different action files (insertrecord.php, insertrecord2.php). Here is the sample code :
Is it possible to create two actions for only one form using javascript or php or any html trick ?

/** sample code */
<form action="process1.php" action="process2.php"  name="myform"> # !!!! pay attention here

   <input type="text" name="First_Name">
   <input type="text" name="Last_Name">
   <input type="submit" value="Submit Form" name="submit">

</form>

It is kinda long story why do I need it, but I really needed.
Thank you
0
hpolat
Asked:
hpolat
  • 2
  • 2
1 Solution
 
Pratima PharandeCommented:
<form  name="myform" method="post" target=_blank>

   <input type="text" name="First_Name">
   <input type="text" name="Last_Name">
   <input type="button" value="Submit Form" name="submit1" onclick="submitform()">

</form>
Jaascript function

function submitform()
{
document.myform.action = "1.asp";
document.myform.submit();
document.myform.action = "2.asp";
document.myform.submit();
}
0
 
hpolatAuthor Commented:
when I try your form it works, after I adjust my code it doesn't. if I use button it doesn't do anything, but if I do submit then it only pops the first ation but second action doesn't start :(
HERE IS MY CODE, ANY THOUGHTS ?

basically I have
<FORM id="formvip" method="POST" E="formvip" onSubmit="return vipvalidate()" target=_blank name="formvip" >
            <!-- DO NOT MODIFY: the hidden input field with id "webformid" -->
            <input type="hidden" name="webformid" id="webformid" value="b15c6d29-d71b-4e47-ac86-b8a256ff5c74" />
                  <INPUT id="vipparty" TYPE="hidden" NAME="vipparty" value=""><br>
....
....
....
.....
                  <input type="submit" name="submit" value="<-- S U B M I T -->" STYLE="background:990000; color:#999999" onClick="submitform()">
                  </FORM>
           
<SCRIPT language = "javaScript">
            function submitform()
            {
            document.formvip.action = "las_vegas_bachelor_bachelorette_party_processformvip1.php";
            document.formvip.submit();
            document.formvip.action = "las_vegas_bachelor_bachelorette_party_processformvip2.php";
            document.formvip.submit();
         
            }
 </SCRIPT>  
0
 
Pratima PharandeCommented:
type of button in button not submit

 type="button"

<input type="button" name="submit" value="<-- S U B M I T -->" STYLE="background:990000; color:#999999" onClick="submitform()">
0
 
hpolatAuthor Commented:
I did that, and now when I click the submit button, nothing happens and the bottom right corner of the internet explorer displays a message : "Eror on page;"
any idea ?
thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now