I have a problem that it is driving me crazy. I have radio buttons on my Visualforce page, some of the radio buttons are hidden when you first open the page, but if let's say the radio button #10 is changed to the option 'Yes', I refresh the page and show 2 more radio buttons.

My problem is that it's always reloading the page to the top and I don't want it. I have this radio buttons inside pageblock and outputpanel. I was able to make it work to go to a button but not a radio button.

On Apex I have differents functions to each radio button that displays hidden radio buttons. I called this function like this:

<apex:selectRadio value="{!contact.LivesInAmerica__c}" label="Do you live in America?" id="rb1">
    <apex:selectoptions value="{!types}"></apex:selectoptions>
    <apex:actionSupport event="onchange" action="{!functionFirst}"/>
<apex:selectRadio rendered="{!showRB1}" value="{!contact.Street__c}" label="Street">
     <apex:selectoptions value="{!types}"></apex:selectoptions>

And this code on Apex Class Controller:

public PageReference functionFirst(){
    if(contact.LivesInAmerica__c == 'Yes'){
        showRB1= true;
    else {
        showRB1= false;
    return null;


  • 2
    You can write your function as: public void functionFirst() { showRB1 = contact.LivesInAmerica__c == 'Tes'; } No need for a return value or if statement here.
    – sfdcfox
    Feb 23 '18 at 15:53

Add a reRender target, and the page won't move:

<apex:actionSupport event="onchange" action="{!functionFirst}" reRender="theForm" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.