Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Changing a form's target through javascript

Changing a form's target through javascript

Scheduled Pinned Locked Moved Web Development
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    William Engberts
    wrote on last edited by
    #1

    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

    I 1 Reply Last reply
    0
    • W William Engberts

      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

      I Offline
      I Offline
      I am BATMAN
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups