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 Quote Link to comment 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; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.