문제

<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