Frage

<form action="/foo">
        <input type="text" name="q">
        <input type="submit" >
</form>

In the previous HTML, if the user types in 'bar' and clicks the button it would submit to example.com/foo?q=bar. How can I make it go to example.com/foo/bar? I can easily do it with JS but I'm trying to stick to HTML.

War es hilfreich?

Lösung

There is no way to do this in HTML, you need a programming language.

Have something on the server process the form an issue an HTTP 301 response with a Location header.

You could enhance that by use the form's submit event to prevent the default action and set location in JS.

Andere Tipps

You cannot change the value of the action attribute with HTML only. You need to use JS or any other scripting language.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top