Jump to content

change action of form


ldoozer

Recommended Posts

hi all i am trying to change the action of a form depending on a users preferences.

 

can anyone suggest the best way to do this.

 

i currently have this:

<script lang="javascript">
<!--
function formCheck() {
if (document.BuyForm.method.value == "cheque") {
document.BuyForm.action="formail.php";
} else {
document.BuyForm.action="https://select.worldpay.com/wcc/purchase";
}
}
//-->
</script>

 

but it doesn't work :(

Link to comment
Share on other sites

attach an id to the method field and do an onchage event to fire your formcheck function

 

ex:

 

function methodChange(){

var method = document.getElementById('methodid');

method.onchange = formCheck(method.value);

}

 

function formcheck(method){

var act = 'default action';

var for = document.getElementById('formid');

switch(method){

case 'cheque': act = 'new action'; break;

}

for.action = act;

}

 

window.onload = methodChange;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.