HTML <select>フォーム属性

❮HTML5<select>タグ

フォームの外側にあるドロップダウンリスト(ただし、フォームの一部):

<form action="/action_page.php" id="carform">
  <label for="fname">Firstname:</label>
  <input type="text" id="fname" name="fname">
  <input type="submit">
</form>

<label for="cars">Choose a car:</label>
<select name="cars" id="cars" form="carform">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

定義と使用法

このform属性は、ドロップダウンリストが属するフォームを指定します。

この属性の値は 、同じドキュメント内の要素のid属性と同じである必要があります。 <form>


ブラウザのサポート

Attribute
form Yes Yes Yes Yes Yes

構文

<select form="form_id">

属性値

Value Description
form_id Specifies the form element the <select> element belongs to. The value of this attribute must be equal to the id attribute of a <form> element in the same document.

❮HTML<select>タグ