HTMLSelectElement: form プロパティ

HTMLSelectElement.form は読み取り専用のプロパティで、この要素が関連付けられているフォームを表す HTMLFormElement を返します。この要素が <form> 要素に関連付けられていなかった場合は、null を返します。

HTMLFormElement です。

html
<form id="pet-form">
  <label for="pet-select">ペットを選択してください</label>
  <select name="pets" id="pet-select">
    <option value="dog"></option>
    <option value="cat"></option>
    <option value="parrot">オウム</option>
  </select>

  <button type="submit">送信</button>
</form>

<label for="lunch-select">ランチを選んでください</label>
<select name="lunch" id="lunch-select">
  <option value="salad">サラダ</option>
  <option value="sandwich">サンドウィッチ</option>
</select>

<script>
  const petSelect = document.getElementById("pet-select");
  const petForm = petSelect.form; // <form id="pet-form">

  const lunchSelect = document.getElementById("lunch-select");
  const lunchForm = lunchSelect.form; // null
</script>

仕様書

Specification
HTML Standard
# dom-fae-form-dev

ブラウザーの互換性

BCD tables only load in the browser