www.webdeveloper.com
Results 1 to 7 of 7

Thread: Dual form submit doesn't work??

  1. #1
    Join Date
    Mar 2013
    Posts
    9

    Dual form submit doesn't work??

    I have two forms, one is sent to an email processor, the other is sent to Paypal credit card processing.
    I'm trying to launch them from javascript after checking for errors.
    If I do
    if(!errorFlag) UserInfo.submit(); //IT WORKS FINE AND SENDS EMAIL
    If I do
    if(!errorFlag) CreditCard.submit(); //IT WORKS FINE AND SUBMITS CREDIT CARD INFO FOR PROCESSING

    BUT If I do
    if(!errorFlag) {UserInfo.submit(); CreditCard.submit();} // IT ONLY DOES THE SECOND ONE, I NEVER GET THE EMAIL.

    How do I get it to submit both forms?

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    Use Ajax not to change the page with submission ?

  3. #3
    Join Date
    Mar 2013
    Posts
    9
    I don't have AJAX . But are you saying it won't work in Javascript? It seems elementary.

  4. #4
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    That is not a javascript problem. A submission load normally an other page !
    Then the original page can not call a second page...
    It's not possible to explain why the second form only work without your form structures and actions ?
    Last edited by 007Julien; 03-29-2013 at 10:25 AM.

  5. #5
    Join Date
    Mar 2013
    Posts
    9
    OK Thanks everyone. I"ll try setting a flag in cookies and use that to trigger the credit card processing after doing a return from the email processing .php script.

    I was reluctant to do that incase it failed to get back and missed processing the credit card. But this is the best route because I can't be sure they will always use the return link from the credit card processing.

  6. #6
    Join Date
    Mar 2011
    Posts
    1,139
    The basic problem is that the process of submitting a form from a webpage requires sending an HTTP request to the 'action' URL for the form. This means that the current page unloads and the browser displays the response to its HTTP request, so, essentially, the second form on your page no longer 'exists'.

    AJAX is a part of JavaScript, and is supported in all browsers. So 007Julien is correct that you could use it to submit the contents of the EMail form in the background (and not worry about the response), and then let the page process the submission of the PayPal form normally. It wouldn't be difficult, and if you search on "AJAX tutorial' I'm sure you could learn how to do it in a very short time. But there might be a better way all around.

    Some PayPal shopping cart functions offer a callback notification that can be sent back to your website. That notification would show whether or not the user's payment was received, so you could have a script on your site that would send a message only if the payment went through properly. You might look into that. Good luck!
    Rick Trethewey
    Rainbo Design

  7. #7
    Join Date
    Mar 2013
    Posts
    9
    Cool, thanks Rick.

    I will investigate the AJAX solution. A little education is a good challenge, I've been programming computers for over 50 years but mostly assembly language in small computers.

    The "Better way" won't work. The problem is the email submission sends ME the details of the purchase. Paypal used to supply 10 "User Fields" that would store the necessary transaction and customer information I supply and return them with the acknowledgement, BUT they discontinued that leaving only two very small "Comment" fields (128 characters I think) that are way too small to save the transaction information I need.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles