Thuộc tính biểu mẫu HTML <select>

❮ Thẻ <select> HTML5

Thí dụ

Danh sách thả xuống nằm bên ngoài biểu mẫu (nhưng vẫn là một phần của biểu mẫu):

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

Định nghĩa và Cách sử dụng

Thuộc formtính chỉ định hình thức mà danh sách thả xuống thuộc về.

Giá trị của thuộc tính này phải bằng idthuộc tính của một <form> phần tử trong cùng một tài liệu.


Hỗ trợ trình duyệt

Attribute
form Yes Yes Yes Yes Yes

Cú pháp

<select form="form_id">

Giá trị thuộc tính

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.

❮ Thẻ <select> HTML