我在使用单选按钮的disable属性时遇到问题。因此,在我的基于when语句的代码中,我需要预先选择一个单选按钮并禁用它,以便用户无法更改它。代码在前端工作正常,但是当我将表单提交给DB时,该按钮的值变为空。
<c:when test="${DATA_WAREHOUSE != null && DATA_WAREHOUSE == 'CNS'
&& DATA_WAREHOUSE_RESPONSE != null && DATA_WAREHOUSE_RESPONSE == 'CNS_0'}">
<label for="rMailer" class="radio-wrap">
<input type="radio" name="maileraddressee" value="MAI" id="rMailer" checked disabled>
I was the mailer
</label>
<label for="rAddressee" class="radio-wrap">
<input type="radio" name="maileraddressee" value="ADD" id="rAddressee" disabled>
I was the addressee
</label>
<input name="mailerAddressee" value="MAI" type="hidden"/>
</c:when>
答案 0 :(得分:1)
您无需禁用已选中的单选按钮。如果该组中的其他单选按钮被禁用,则用户将无法取消选中加载页面时检查的按钮。
<label for="rMailer" class="radio-wrap">
<input type="radio" name="maileraddressee" value="MAI" id="rMailer" checked="checked">
I was the mailer
</label>
<label for="rAddressee" class="radio-wrap">
<input type="radio" name="maileraddressee" value="ADD" id="rAddressee" disabled="disabled">
I was the addressee
</label>
如果您现在提交表单,则应获得maileraddressee
的MAI值。