2
1

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

Thymeleafでラジオボタンをreadonlyっぽくする

Last updated at Posted at 2020-12-24

ラジオボタン

th:disabledで選択してないボタンをdisabledにする。
これだけ。

<input type="radio" name="gender" id="gender" value="男性" th:checked = "${gender == '男性'}" th:disabled="${gender != '男性'}">
<input type="radio" name="gender" id="gender" value="女性" th:checked = "${gender == '女性'}" th:disabled="${gender != '女性'}">

セレクトボックス

セレクトボックスはth:textとvalueに値を突っ込んでしまえばOK。

<select id="birthYear" name="birthYear">
	<option	th:text="${birthYear}" th:value="${birthYear}"></option>
</select>
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?