If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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.

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 ?

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.

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!

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.