

Consider the following situation: you would like a set of radio buttons on a form that will have a value preselected. You don’t want to give the user the option to change the selected radio button, but you do want to submit that value with the form.
Using the disabled attribute doesn’t work because it doesn’t submit the value with the form. Using the readonly attribute doesn’t work with radio buttons.
This can be accomplished by simply adding an onclick=”return false;”. This also allows the radio buttons to look normal without being grayed out.
The only caveat I’ve found with this is that the selection has to be made ahead of time or the first one the user clicks on will be selected and then the user cannot select another one. One way of dealing with this is by using a default value you would like submitted with the form if none of the values are selected. Then just use a style=”display:none;” to hide this button from the user. All the other radio buttons will remain unselected and unable to change.

Click to get started.
1 comment(s)
Comments
1 issue with proposal
Thanks for this, but there's still 1 issue with the proposal. If you click another radio button, the radio button you originally set (and wanted displayed) has its checked value disappear. By using a hidden field, nothing is really lost, but visually, the user will see only blank radio buttons. If the user clicks the original button, then it should redisplay so long as you don't assign the onclick="return false" to it. All this was on IE v7. Thanks, again.