View Full Version : Dual Action Submit Button on a Form

Sep 20th, 2010, 05:30 PM
Hi Experts,

Is it possible to have a dual action SUBMIT button on a form. For ex:

Action -1) When the user clicks on a SUBMIT button the data gets saved to the database (which it does right now)

Action -2) And at the same time redirect the user to merchant HTTPS Site for online payment processing .- How do I do this??

I want to incorporate the below code into the submit button as a secondary action.

<form action="https://www.myvirtualmerchant.com/VirtualMerchant/process.do" method="POST">
<input type="hidden" name="ssl_merchant_id" value="my_virtualmerchant_ID">
<input type="hidden" name="ssl_user_id" value="my_User_ID">
<input type="hidden" name="ssl_pin" value="my_PIN">
<input type="hidden" name="ssl_show_form" value="true">
<input type="hidden" name="ssl_test_mode" value="false">
<input type="hidden" name="ssl_invoice_number" value="???? PASS INVOICE">
<input type="hidden" name="ssl_transaction_type" value="ccsale">
<input type="hidden" name="ssl_amount" value="???????? PASS TOTAL $$$">
<input type="submit" value="Click Here to Complete Your Order - USE FORM BUTTOM">

I would like to use one SUBMIT button for both actions. Thanks in advance for your help.


Sep 21st, 2010, 11:29 AM
You would be better to forward the user on the next page (process.do) to go to the merchant unless you don't have access to the code on that page.

If you don't you may have to get the form to call a javascript function:

<form action="javascript:doSubmit();">

which will use AJaX to submit the data to the database, check for an error-free return and if there is, use javascript to fill a duplicate hidden form with the data from the first form and then submit that second form (give the hidden form the action to submit to the merchant site).

I hope that helps a little.

Sep 22nd, 2010, 11:12 AM
but then also bare in mind if you use javascript that not everyone will have it enable meaning the action will not be carried out!

Sep 23rd, 2010, 02:57 AM
Thanks for the suggestions Stooshie and Carl.

Sep 27th, 2010, 01:50 PM
CarlLaw has a point but even creating, say, an intermediate page would require javascript unless you want the user to submit the second page as well.

The majority of users do have javascript enabled however. Many websites are unusable without client side scripting of one form or another.