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 5 years have passed since last update.

selectのvalueが取得できなかった原因

Posted at

何がしたいか

selectフォームの値をデフォルト値の空文字で受け取りたい。

問題のコード

<select name="dayOfWeeks">
  <option value="" selected disabled>選択</option>
  <option value="月">月曜日</option>
  <option value="火">火曜日</option>
  <option value="水">水曜日</option>
  <option value="木">木曜日</option>
  <option value="金">金曜日</option>
  <option value="土">土曜日</option>
  <option value="日">日曜日</option>
</select>

原因

disabledを指定しているとvalueが取れない!!
disabledで無効化しているので、言われてみれば納得です。
でもそんなの知らなかったです。勉強になりました。

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?