0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[HTML] <form> の action についての調査

Last updated at Posted at 2020-08-22

概要

  • <form method="GET"> の action に get query を付与した場合の振る舞いを調べてみました。

結果

  • method="GET" で action に get query を付与しても、form data で生成された query で上書きされてしまうようです。
actionにURLのみ指定
<form
  action="test.html"
  method="GET"
>
  <input name="text" value="Sending-text">
  <button type="submit">Send</button>
</form>

// 遷移先: .../test.html?text=Sending-text
actionにURLとqueryを指定
<form
  action="test.html?name=stew&amp;title=test"
  method="GET"
>
  <input name="text" value="Sending-text">
  <button type="submit">Send</button>
</form>

// 遷移先: .../test.html?text=Sending-text
  • POST の場合、URL に付与した query はそのままでした。
method=POSTでactionにURLとqueryを指定
<form
  action="test.html?name=stew&amp;title=test"
  method="POST"
>
  <input name="text" value="Sending-text">
  <button type="submit">Send</button>
</form>

// 遷移先: .../test.html?name=stew&title=test
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?