|
|
Subject:
Javascript or PHP code to alter the form action depending on a button
Category: Computers > Programming Asked by: toph-ga List Price: $2.00 |
Posted:
03 Aug 2002 13:40 PDT
Expires: 02 Sep 2002 13:40 PDT Question ID: 50250 |
I am working on a form that can be viewed at: http://www.nrcpara.org/bookstore/testing/orderform.php I need to be able to alter the action of the form depending on whether the user selects to to pay by Credit Card (type=payment name=card) or Money Order (type=payment name=check). For example, if the Credit Card option is selected, it will go to one URL, but if the Money order button is selected it will go to another. Thanks, Christopher |
|
Subject:
Re: Javascript or PHP code to alter the form action depending on a button
Answered By: dms-ga on 03 Aug 2002 14:32 PDT Rated: |
Hi Christopher, A simple piece of javascript will solve your problem... Add the code below to your page. It will work with both IE and Netscape. Add the this onclick event to your payment radio buttons: onclick="changePaymentType()" <input type="radio" name="payment" onclick="changePaymentType()" value="card" checked> <input type="radio" name="payment" onclick="changePaymentType()" value="check"> Put this script block somewhere on your page (you'll need to replace the url's with the correct one's): <script language="javascript"> function changePaymentType(){ var myForm = document.forms.form1 if (myForm.payment[0].checked){ myForm.action = 'myUrl1.php' }else{ myForm.action = 'myUrl2.php' } } </script> Good luck! Daaf | |
| |
|
toph-ga rated this answer: |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |