Sometimes, we want to set the form action through JavaScript.
In this article, we’ll look at how to set the form action through JavaScript.
How to set the form action through JavaScript?
To set the form action through JavaScript, we set the action
property.
For instance, we write
document.getElementById("form_id").action = "script.php";
to select the form with getElementById
.
Then we set its action
property to the action
attribute value.
Conclusion
To set the form action through JavaScript, we set the action
property.