html - 双列表框禁用选择选项
问题描述
我正在使用从http://www.virtuosoft.eu/code/bootstrap-duallistbox/获得的 Bootstrap Dual Listbox
我正在使用 Thymeleaf 生成列表框选项。我有这样一个场景——在我的实体中有 BOOLEAN 列名 is_generated,如果 'is_generated=true' 意味着需要禁用基于条件的选项,这意味着用户无法选择特定选项,如HTML 属性 (disabled="true")
这是我的代码
<form id="chargeslistformid" method="post" action="#"
th:action="@{/savechargeslist}" th:object="${wrpAssignCharges}">
<label>
<select id="selectBox" multiple="multiple"
name="selectedChargesList" class="selectpicker form-control" >
<option th:each="charge:${chargeslist}"
th:value="${charge.pkAssignId}"
th:text="${charge.chargeName}"
th:selected="${previouslist.contains(charge)}"></option>
</select>
</label>
<br/>
<button id="chargeslistbtnid" th:type="submit" class="btn btn-info">Next</button>
</form>
请帮帮我...在此先感谢
解决方案
您可以使用 th:disabled 属性根据条件生成禁用属性:
<option
..
th:disabled="${ /* condition, e.g. 1 < 2 or #object.property == ... */ }"
>
</option>
推荐阅读
- linux - 如果遇到意外情况,将文件 2 中的模式替换为文件 1 中的模式
- .net - PowerShell 脚本未创建 WinSCP 会话的日志文件
- api - Oauth + SPA + API 后端
- html - 我的滑块占据了整个屏幕我该怎么办
- android - 无法在 Android Studio 上编译 Apk
- javascript - 当满足条件时,如何仅为实例执行嵌套 for 循环内的代码?
- haskell - 用 let fun x = x + 1 形式定义 Haskell 函数
- java - 来自 Android Visualizer 的 FFT 数据取决于音量
- angular - Visual Studio Code compileOnSave 停止工作
- python - 从文本文件中读取,如果列表中有句子定义