Need Help w/Multiple form submit actions

Discussion in 'Javascript' started by Sophisticado, May 1, 2005.

  1. Sophisticado

    Sophisticado Guest

    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?
     
    Sophisticado, May 1, 2005
    #1
    1. Advertising

  2. 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
     
    David Dorward, May 1, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ice
    Replies:
    4
    Views:
    6,208
    David Dorward
    Nov 2, 2003
  2. Replies:
    4
    Views:
    935
  3. Just Me
    Replies:
    4
    Views:
    377
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    May 8, 2007
  4. sam

    Multiple submit actions.

    sam, Dec 28, 2004, in forum: Perl Misc
    Replies:
    21
    Views:
    459
    Matt Garrish
    Dec 31, 2004
  5. Replies:
    3
    Views:
    701
Loading...

Share This Page