Want Submit button to send 2 scripts

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have an invoice form that I want sent via a PayPal cgi link when I press a
Submit button. However, I also want to send a copy of the form via email to
the client using my own email cgi script. Formerly I used the following FORM
tag to send the PayPal cgi only:

<form id="f1" action="paypal_cgi_link" ...onSubmit="return

<input type="submit" name="PayPal">

I want to know if the following attempt would work to send both scripts.

<form id="f1" action="paypal_cgi_link" ...>

<input type="button" name="Button" value="PayPal" onClick="return
finalCall(document.forms["f1"].elements);myEmailscript();alert("An email was

Thanks for any assistance.

Re: Want Submit button to send 2 scripts

M.L. wrote:

Quoted text here. Click to load it

I might not understand your question, is the form actually submitting to
a script, or is it just using JavaScript to display an alert based on
what they've filled into the form fields?  I assume that the one part
is just the JavaScript alert notice, and the second part is the part
that actually submits to the script where all of the actual work is
done (if not, that would be the (better) solution anyway). The script
can just then do the needed work and send an email and do a hundred
other things from the one submission (hopefully verified submission by
checking in the script (CGI, PHP, etc. script), and not just using
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Re: Want Submit button to send 2 scripts

M.L. wrote:
Quoted text here. Click to load it

Are you using PayPal Instant Payment Notification? If you are, have the
script the receives the Notification send the email to your client.
Otherwise, is it possible to call your own script, send the notification
to the client, then have your script pass the info to PayPal?

Re: Want Submit button to send 2 scripts

Quoted text here. Click to load it

No, I'm not using IPN, I just want PayPal to bill them for the invoice
amount and be done with them. PayPal does not recommend using IPN for my

After more searching, someone found that they could execute 2 actions by
separating them with a comma.

<form id="f1" action="http://...paypal.cgi", http://...myEmail.cgi
method="post" ...>

However, it was not certain that that solution would work across browsers so
I abandoned that method and decided to launch 2 actions by using 2 different
submit-type buttons. I used the code created by someone else, as follows:

<form action="" id="f1" name="f1"
enctype="application/x-www-form-urlencoded" method="post">
<input type="button" value="Send Email"
<input type="button" value="Send to PayPal"
function sendEmail(inputObj)
    if (finalCall(inputObj))
      document.f1.action = "http://www.mydomain.com/cgi-bin/myEmail.cgi ";
      document.f1.submit();                         // Submit the page
    else {alert ("No emails were sent.");}
function sendPayPal(inputObj)
    if (finalCall(inputObj))
      document.f1.action = "https://www.paypal.com/cgi-bin/webscr ";
      document.f1.target = "_blank";            // Open in a new window
      document.f1.submit();                        // Submit the page
    else {alert ("Nothing sent to PayPal.");}

Thanks to all who replied for their assistance.

Site Timeline