Changing a form's target through javascript
-
Hi guys, I am currently writing the payment part of a webshop. There are three ways of payment, and the customer szelects one of these three by means of a selection in the form. The actual submit button start a javascript function that checks the payment method and sets the form's target to a intermediate page for each of the three payment methods. The code I use is very simple: if (document.orderform.method[0].checked == true) { document.orderform.target = '_self'; document.orderform.submit(); } else if (document.orderform.method[1].checked == true) { document.orderform.target = '_self'; document.orderform.action = 'ideal.php'; document.orderform.submit(); } else if (document.orderform.method[2].checked == true) { document.orderform.target = '_blank'; document.orderform.action = 'paypal.php'; document.orderform.submit(); } else alert ("please select a payment method"); This works fine in firefox, however IE7 says "object doesn't support this property or method" This occurs at "...action='ideal.php';" When I give the action a value (document.orderform.action.value='ideal.php') IE does not complain, but does not change the form's action either (also firefox does not change the action anymore) Does anyone have a suggestion on how to change the form's action in all browsers? Any suggestions are greatly appreciated. Thanks in advance, William
-
Hi guys, I am currently writing the payment part of a webshop. There are three ways of payment, and the customer szelects one of these three by means of a selection in the form. The actual submit button start a javascript function that checks the payment method and sets the form's target to a intermediate page for each of the three payment methods. The code I use is very simple: if (document.orderform.method[0].checked == true) { document.orderform.target = '_self'; document.orderform.submit(); } else if (document.orderform.method[1].checked == true) { document.orderform.target = '_self'; document.orderform.action = 'ideal.php'; document.orderform.submit(); } else if (document.orderform.method[2].checked == true) { document.orderform.target = '_blank'; document.orderform.action = 'paypal.php'; document.orderform.submit(); } else alert ("please select a payment method"); This works fine in firefox, however IE7 says "object doesn't support this property or method" This occurs at "...action='ideal.php';" When I give the action a value (document.orderform.action.value='ideal.php') IE does not complain, but does not change the form's action either (also firefox does not change the action anymore) Does anyone have a suggestion on how to change the form's action in all browsers? Any suggestions are greatly appreciated. Thanks in advance, William
run this through jslint, tips: always use triple = for comparison (===) opening brackets must come on the same line as the conditional statement opening them, Javascript does strange things in certain situations if it's on the next line.