473,774 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help w/Multiple form submit actions

Hi

Newbie here. I am trying to have two form actions on submission using a
javascript. The first calls a php class (http://www.blah.org/test.php)
and the second adds data to a mySQL database via a php function call (<?
php echo $editFormAction ; ?>. Both actions work; however, only the
second action in the fucntion runs. Here is the code:

<script language=javasc ript>
<!--
function But1()
{
document.form1. action = "http://www.blah.org/test.php"
document.Submit Abstract.submit (); // Submit the page
document.Submit Abstract.action = <?php echo $editFormAction ; ?>;
document.Submit Abstract.submit ();
return true;
}
-->
</script>

In this example, the document.Submit Abstract.action = <?php echo
$editFormAction ; ?>; action works fine. If I reverse the order:

<script language=javasc ript>
<!--
function But1()
{
document.Submit Abstract.action = <?php echo $editFormAction ; ?>;
document.Submit Abstract.submit ();
document.form1. action = "http://www.blah.org/test.php"
document.Submit Abstract.submit (); // Submit the page
return true;
}
-->
</script>

only the test.php file runs. Any ideas?
Jul 23 '05 #1
1 1733
Sophisticado wrote:
document.Submit Abstract.action = <?php echo $editFormAction ; ?>;
document.Submit Abstract.submit ();
document.form1. action = "http://www.blah.org/test.php"
document.Submit Abstract.submit (); // Submit the page
return true; only the test.php file runs. Any ideas?


The browser can't visit two webpages at the same time (unless you start
mucking about with new windows or frames). Depending on client side
scripting is unwise anyway.

The best solution is almost certainly to combine the functions of all your
form handlers into one handler script, then look at which submit button was
clicked in the form handler to decide what actions to take. (Thus
eliminating the need for JavaScript entirely).

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7794
by: Sarah | last post by:
Hi all. I have a form, and several text and image links on it that should submit the form with different actions. I prepared a simple page with just the code that's not working. PROBLEM: The form won't submit if the link is clicked, but will submit if the SUBMIT button is clicked. I need to call a function to change the form's action according to user's input before it is submitted.
3
7021
by: M Wells | last post by:
Hi All, I'm trying to build a page where a user can enter comments and I want to add a 'Preview' button to the form. When the user clicks on the 'Preview' button I'd like the same form to submit to the current page, however, when the user clicks on the submit button, I'd like the form to submit to another processing page. In other words, I basically want two distinct form actions -- one to
2
2110
by: Matt | last post by:
The ASP page has multiple buttons, and when the user clicks different buttons, it will submit the form data to different URLs. My first approach was to use BUTTON type, and triggers javascript function to submit the form data. However, it didn't work properly and I changed to use SUBMIT type. <INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page" onClick="action1()">
9
14750
by: Mark | last post by:
I have a lengthy form (i.e., many inputs) on my form.php page. What's different about this form than many others I've created is that I want the user to have a choice of submitting this form data to one of two pages, choice1.php or choice2.php, both of which read $_POST data from the form. Obviously, a 'submit' button will send the user to the page specified by the form's 'action=' setting, so I would have to employ some sort of trick....
1
1554
by: elia | last post by:
Hello, I can't do two actions wich must be done on a form having two buttons. (payment by invoice and payment by Credit card) The first action establishes a link on two differents pages according to whether one wants to pay by invoice or credit card. (2 buttons send) The second action is for check if all the fields were filled.
5
2010
by: Tyrone Slothrop | last post by:
I have created a form which has two submit buttons. The first is a preview button to view the data they have entered into a formated page. The second actually submits the data for saving. The two submit buttons have onclick events defined for both the targets and actions. These are both working OK. However, I have an onsubmit event in the form tag which validates the data which is also triggered when the preview button is clicked. I...
7
10293
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still lack some JavaScript solid knowdlege) The problem is that when I try to send a form's content with Ajax (I'm using the prototype library), for some reason the latin characters (accents and stuff, like áéíóú) turn a mess when I try to store them in...
5
1814
by: zoomcart.com | last post by:
Hello and thanks in advance for your help. I have code below that posts form data to a cgi scripted shopping cart and it works great on my mac/firefox browser, but it doesn't work on ibm/netscape machines. what gives? apparently the data isn't being recognized and so the cart defaults to it's home page. <form name='submit3' action='http://my.com/cart.cgi' method='post'> <input type='hidden' name='user' value='bighouse'> <input...
6
7572
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created the problem that when I went to select the other drop down menus, the selections i made on the multiple select one would clear. Then I had tried putting the multiple select menu last so that the selections wouldn't clear but then after clicking the...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.