Categories
JavaScript Answers

How to set the form action through JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *