0

I have 2 radio buttons on my vf page YES and NO. On selection of yes a text box should appear and on selection of no should disappear. I tried action support without much success. How do I select a radio value to render?

1 Answer 1

2

It certainly does work. You haven't shared your code, but this is simple enough that a demonstration should illuminate what went wrong:

<apex:page controller="dynSelect">
    <apex:form id="form">
        <apex:selectRadio value="{!selectedOption}">
            <apex:actionSupport event="onchange" rerender="form" />
            <apex:selectOption itemValue="Yes" itemLabel="Yes" />
            <apex:selectOption itemValue="No" itemLabel="No" />
        </apex:selectRadio>
        <apex:inputText rendered="{!selectedOption='Yes'}" />
    </apex:form>
</apex:page>

Note: selectedOption is simply a String variable.

Most likely, you probably tried to use the "onselect" event, which actually doesn't work for radio input values.

2
  • Hi @sfdcfox. Sorry for not sharing the code. It was a question I decided to post just before sleeping. I understand where I went wrong. I wrongly did the following... "<apex:inputText rendered="{!itemValue='Yes'}" />". Thanks for you answer.
    – MnZ
    Jan 13, 2017 at 5:37
  • 1
    @MnZ It's okay. That's why were here.
    – sfdcfox
    Jan 13, 2017 at 5:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .