Solved

Submit one form one button to two different action file ?

Posted on 2008-06-09
4
1,906 Views
Last Modified: 2013-11-19
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
Comment
Question by:hpolat
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 21748674
<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
 

Author Comment

by:hpolat
ID: 21749333
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
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 21749360
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
 

Author Comment

by:hpolat
ID: 21752083
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question