ldoozer Posted September 28, 2007 Share Posted September 28, 2007 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 More sharing options...
emehrkay Posted September 28, 2007 Share Posted September 28, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.