You need to sign in to do that
Don't have an account?
sbrmath
Making radio button label clickable
How can i make the radio button as well as label for the radio button clickable?
Code:
<apex:outputLabel value=""/>
<table border="0">
<tr>
<td>
<apex:selectRadio id="searchType" layout="pageDirection" disabled="true" value="{!searchType}" onclick="setSearchType(this);" styleClass="radio_b">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio>
</td>
</tr>
</table>
In that case, a real radiobutton (selectradio) is probably not the best solution. Here's the skeleton of some markup that would depend upon apex to determine the states of checkboxes which are ouputs, not inputs. Then you surround the checkbox and label with a clickable outputpanel. You'll need to rerender an element that contains the other checkboxes (whose state may have changed).
<apex:actionRegion immediate="true"> <apex:outputpanel> <apex:actionSupport event="onclick" action="{!myAction}" status="updating" rerender="element_to_rerender"/> <apex:outputLabel value="my label name" for="the_checkbox"/> <apex:outputCheckBox value="{!myvariable}" id="the_checkbox"/> </apex:outputpanel> </apex:actionRegion> <apex:actionStatus startText="updating..." id="updating" />
All Answers
Radio buttons (the html elements) work in an unusual way. I suggest that you use checkboxes, and implement the radiobutton behavior (pushing one pops any others that are pushed) in apex. This wiki article on wrapper classes has some inspiration.
Also, your code was mangled by the forum software. Next time you are posting some code, try using the "code submit" button. It looks like a clipboard with a "C" attached (just to the right of bold, italic, underline, etc on the toolbar).
If you are using Firefox, your code formatting will be preserved. Sadly, if you are using chrome or safari, it will be mangled in a different way.
In that case, a real radiobutton (selectradio) is probably not the best solution. Here's the skeleton of some markup that would depend upon apex to determine the states of checkboxes which are ouputs, not inputs. Then you surround the checkbox and label with a clickable outputpanel. You'll need to rerender an element that contains the other checkboxes (whose state may have changed).
<apex:actionRegion immediate="true"> <apex:outputpanel> <apex:actionSupport event="onclick" action="{!myAction}" status="updating" rerender="element_to_rerender"/> <apex:outputLabel value="my label name" for="the_checkbox"/> <apex:outputCheckBox value="{!myvariable}" id="the_checkbox"/> </apex:outputpanel> </apex:actionRegion> <apex:actionStatus startText="updating..." id="updating" />
Thanks shikibu!