Вопрос

<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.

Это было полезно?

Решение

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.

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top