[Javascript] Two Actions with one form
Paul Novitski
paul at novitskisoftware.com
Sun Mar 26 16:06:41 CST 2006
>At 12:51 PM 3/26/2006, Del Wegener wrote:
>>Upon submission of a form I would like two actions to happen:
>>action="/cgi-bin/bizdb-aed.cgi" to put the contents of the
>>form in a database
>>action=https://www.paypal.com/cgi-bin/webscr
>>
>>How do I accomplish this?
>>
>>I am guessing JavaScript -- that's why I tried this list.
At 01:26 PM 3/26/2006, Paul Novitski wrote:
>Del,
>
>I don't know of a way to insert data in a database using JavaScript,
>which is prevented from writing to files on the client computer for
>security reasons and has no way to write to files on the server
>because it's running on the client.
>
>I'd say what you want to do is submit your form to a server-side
>script (PHP etc.) that writes values to the database then redirects
>to the destination page.
Sorry, Del, I answered too quickly. You've already got a CGI script
writing to the database. If this functions like most server-side
scripts, you can redirect to the paypal page from the CGI script
after it's written to the db. If you can't do this for some reason
and you really need to execute two requests from your page of origin,
then yes, you could do this from JavaScript.
One way to do it would be to trigger the CGI with an image url +
querystring, such as:
var oImg = new Image;
oImg.src = "/cgi-bin/bizdb-aed.cgi?field1=datum1&field2=datum2";
Use JavaScript to build the querystring, create the image object, and
set the image src. There will of course be no image file that
results, but the HTTP request will execute in real time.
Then you can redirect the user to the destination page:
document.location.href = "https://www.paypal.com/cgi-bin/webscr";
and you're done.
Paul
More information about the Javascript
mailing list