I have a <form> with an action attribute.
I would like to change the value of action based on the value of an <input>.
The value is provided by the user. If the value is page1.php, the form will be submitted to page1.php. If the value is page2.php, the form will be submitted to page2.php, and so on.
Right now I’m achieving this using JavaScript, however it doesn’t work on a browser with JavaScript disabled.
Is there any way to make the action non-static without JavaScript?
If you just want to receive the value on the server side, than using
getas the form’smethodwill work (you end up withpage.php?my_var_name=my_var_value).If, however, you want to direct the form to a completely different page based on the value of your input, you’ll either have to use JS, or have a “catchall” page on the server side that gets the form and redirects to the final page based on the value.