473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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=javascript>
<!--
function But1()
{
document.form1.action = "http://www.blah.org/test.php"
document.SubmitAbstract.submit(); // Submit the page
document.SubmitAbstract.action = <?php echo $editFormAction; ?>;
document.SubmitAbstract.submit();
return true;
}
-->
</script>

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

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

only the test.php file runs. Any ideas?
Jul 23 '05 #1
1 1710
Sophisticado wrote:
document.SubmitAbstract.action = <?php echo $editFormAction; ?>;
document.SubmitAbstract.submit();
document.form1.action = "http://www.blah.org/test.php"
document.SubmitAbstract.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
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:...
3
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...
2
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...
9
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...
1
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...
5
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...
7
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...
5
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...
6
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.