Reputation: 87
I am having issues with using the disable attribute for the radio buttons. So in my code based on the when statement I need to preselect a radio button and disable it as well so user cant change it. The code works fine on the front end but when I submit the form to DB the value for that button becomes null.
<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>
Upvotes: 0
Views: 3886
Reputation: 6522
You don't need to disable the checked radio button. If the other radio buttons in that group are disabled, the user won't be able to uncheck the one that was checked when the page loaded.
<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>
If you submit the form now, you should get a value of MAI for maileraddressee
.
Upvotes: 3