2014-10-20 98 views
0

我对使用单选按钮的禁用属性存在问题。所以在基于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> 

回答

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值。