By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

Need Help w/Multiple form submit actions

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.