471,350 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 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 1646
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by M Wells | last post: by
2 posts views Thread by Matt | last post: by
9 posts views Thread by Mark | last post: by
1 post views Thread by elia | last post: by
5 posts views Thread by Tyrone Slothrop | last post: by
5 posts views Thread by zoomcart.com | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.