In visualforce page I have a custom picklist with the values "Show" and "Hide" and two command buttons(Button A & Button B). When the picklist value is "Show", Button B needs to be displayed and when it's "Hide" then Button B needs to be hidden.
For that I have tried below code
Visualforce page :
<apex:page showHeader="false" controller="picklistRenderController">
<apex:form >
<apex:pageBlock >
<apex:selectList value="{!selectId}" size="1">
<apex:selectOptions value="{!display}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!displayButton}" reRender="d"/>
</apex:selectList>
<apex:pageBlockButtons location="bottom" id="d">
<apex:commandButton action="{buttonA}" value="Button A"/>
<apex:commandButton action="{buttonB}" value="Button B" rendered="{!selectId=='show'}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller is :
public class picklistRenderController {
public List<selectoption> display { get; set; }
public String selectId { get; set; }
public PageReference buttonB() {
return null;
}
public PageReference buttonA() {
return null;
}
public PageReference displayButton() {
return null;
}
public picklistRenderController()
{
display =new List<selectoption>();
display.add(new selectoption('none','-select-'));
display.add(new selectoption('show','show'));
display.add(new selectoption('hide','hide'));
}
}
But I couldn't able to get this work. Please help me on this.