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
https://forums.phpfreaks.com/topic/71041-change-action-of-form/
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
https://forums.phpfreaks.com/topic/71041-change-action-of-form/#findComment-357258
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.