Why can't radio buttons be “readonly”?

前端 未结 13 1225
误落风尘
误落风尘 2020-11-27 10:45

I would like to show a radio button, have its value submitted, but depending on the circumstances, have it not editable. Disabled doesn\'t work, because it doesn\'t submit t

13条回答
  •  执笔经年
    2020-11-27 11:11

    I have a lengthy form (250+ fields) that posts to a db. It is an online employment application. When an admin goes to look at an application that has been filed, the form is populated with data from the db. Input texts and textareas are replaced with the text they submitted but the radios and checkboxes are useful to keep as form elements. Disabling them makes them harder to read. Setting the .checked property to false onclick won't work because they may have been checked by the user filling out the app. Anyhow...

    onclick="return false;"
    

    works like a charm for 'disabling' radios and checkboxes ipso facto.

提交回复
热议问题