I have a form and I would like the ACTION field to be different depending on the button pressed.
For instance the form might get processed by different PHP files if I press button A or button B.
How can I do this?
Thanks!
I have a form and I would like the ACTION field to be different depending on the button pressed.
For instance the form might get processed by different PHP files if I press button A or button B.
How can I do this?
Thanks!
In your buttons you can just set the form's action, using it's form
property, for example on button a:
this.form.action = "fileA.php";
On the other:
this.form.action = "fileB.php";
You can rig this up externally, like this:
document.getElementById("buttonA").onclick = function() {
document.getElementById("myForm").action = "fileA.php";
};
Or if you're using a library like jQuery:
$(function() {
$("#buttonA").click(function() {
$(this).closest("form").attr('action', 'fileA.php');
});
});