Unable to select a particular radio button choice by clicking on the choice text

谁说胖子不能爱 提交于 2019-12-24 09:57:10

问题


<s:decorate template="/layout/display-text.xhtml">
    <h:selectOneRadio layout="pageDirection" value="#{_userHome.pref}">
        <f:selectItems value="#{_userHome.getPreferences()}" />
    </h:selectOneRadio>
</s:decorate>

I am able to select user preferences by directly clicking on the text next to the radio button choice in all browsers except Firefox. How should I fix this?


回答1:


You need to add a <label> element for the radio button so that your markup looks as follows:

<label for="radio-button">Radio button label text</label>
<input type="radio" value="1" name="radio-button" id="radio-button"/>

The for and id attributes of the tags must match. To create this label, you can use the <h:outputLabel/> tag.



来源:https://stackoverflow.com/questions/3396351/unable-to-select-a-particular-radio-button-choice-by-clicking-on-the-choice-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!