HTML <form>アクション属性

❮HTML<form>タグ

送信時に、フォームデータを「action_page.php」という名前のファイルに送信します(入力を処理するため)。

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

定義と使用法

このaction属性は、フォームが送信されたときにフォームデータを送信する場所を指定します。


ブラウザのサポート

Attribute
action Yes Yes Yes Yes Yes

構文

<form action="URL">

属性値

Value Description
URL Where to send the form-data when the form is submitted.

Possible values:

  • An absolute URL - points to another web site (like action="http://www.example.com/example.htm")
  • A relative URL - points to a file within a web site (like action="example.htm")

❮HTML<form>タグ