Hello there everybody!
This tutorial is Javascript that allows to modify the action field of an HTML form dynamically.
It is possible to have one submit button in a form but different action url.
The example below show how to switch the action post based on the radio button click.
Add the below sample form to your page:
This is an example search form.
<form method="post" onsubmit="formaction(this)"> <br /> <input type="radio" id="action1" name="search" onclick="keyword1.disabled=false; keyword2.disabled=true; this.form.action = 'action1.php';"><br />Action One <br /> <input disabled="disabled" type="text" name="keyword1" size="40"><br /> <input type="radio" id="action2" name="search" onclick="keyword2.disabled=false; keyword1.disabled=true; this.form.action ='action2.php';"><br />Action Two <br /> <input disabled="disabled" type="text" name="keyword2" size="40"> <br /> <input type="submit" border="0" name="search" id="search" value="Search"> <br /> </form>
Thank you and Enjoy!
