Skip to content
Advertisement

Appending form input value to action url as path

I have a form like this:

JavaScript

If I type a value, let’s say: ‘hello’ in the text input field and submit the form, the URL looks like: http://localhost/test/?keywords=hello.

I want the value to get appended to the action path. So basically, after the form submission the URL should look like:

JavaScript

Advertisement

Answer

You can use onsubmit attribute and set the action inside a function for example:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement