function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
srikanth cheera 11srikanth cheera 11 

Picklist1 and Button1 plz help me

I have one picklist
and I have one vf button

if we choose the value in the picklist only that time button should be apper on the screen plz help me

​plz use only apex and visualforce

Thanks
Best Answer chosen by srikanth cheera 11
Khan AnasKhan Anas (Salesforce Developers) 
Hi Srikanth,

I trust you are doing very well.

Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.

Visualforce:
<apex:page standardController="Account" extensions="TestC">
    <apex:form >
        
        <apex:sectionHeader Title="Address Details" />
        <apex:pageBlock Title="Select the type of Address">
            
            <apex:pageBlockSection columns="1">
                <apex:PageBlockSectionItem >
                    <apex:outputLabel value="Address"/>                    
                    <apex:selectList id="id_1" value="{!Account.Rating}" size="1" >
                        <apex:actionSupport event="onchange" reRender="Container"/>
                        <apex:selectOptions value="{!items}"/>
                    </apex:selectList>                    
                </apex:PageBlockSectionItem>
                
                <apex:PageBlockSectionItem >                    
                    <apex:outputPanel id="Container" >
                        <apex:outputPanel id="ajaxrequest" rendered="{!Account.Rating!=''}" >
                            <apex:commandButton value="Continue"/>
                        </apex:outputPanel>           
                    </apex:outputPanel>
                </apex:PageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public with sharing class TestC {
    
    private Account AD;
    
    public TestC(ApexPages.StandardController stdcontroller) {
        this.AD=(Account)stdController.getRecord();
    }
    
    Boolean disp=False;
    
    Public Boolean getdisp(){
        return disp;
    }
    
    String Values;
    
    public String getValues() {
        return Values;
    }
    
    public void setValues(String Values) {
        this.Values= Values;
        if(Values!=null)
            disp=True;
    }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','None'));
        options.add(new SelectOption('CA','Cease Address'));
        options.add(new SelectOption('CANADA','Canada'));
        options.add(new SelectOption('MEXICO','Mexico'));
        return options;
    }
    
}


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas​

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Srikanth,

I trust you are doing very well.

Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.

Visualforce:
<apex:page standardController="Account" extensions="TestC">
    <apex:form >
        
        <apex:sectionHeader Title="Address Details" />
        <apex:pageBlock Title="Select the type of Address">
            
            <apex:pageBlockSection columns="1">
                <apex:PageBlockSectionItem >
                    <apex:outputLabel value="Address"/>                    
                    <apex:selectList id="id_1" value="{!Account.Rating}" size="1" >
                        <apex:actionSupport event="onchange" reRender="Container"/>
                        <apex:selectOptions value="{!items}"/>
                    </apex:selectList>                    
                </apex:PageBlockSectionItem>
                
                <apex:PageBlockSectionItem >                    
                    <apex:outputPanel id="Container" >
                        <apex:outputPanel id="ajaxrequest" rendered="{!Account.Rating!=''}" >
                            <apex:commandButton value="Continue"/>
                        </apex:outputPanel>           
                    </apex:outputPanel>
                </apex:PageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public with sharing class TestC {
    
    private Account AD;
    
    public TestC(ApexPages.StandardController stdcontroller) {
        this.AD=(Account)stdController.getRecord();
    }
    
    Boolean disp=False;
    
    Public Boolean getdisp(){
        return disp;
    }
    
    String Values;
    
    public String getValues() {
        return Values;
    }
    
    public void setValues(String Values) {
        this.Values= Values;
        if(Values!=null)
            disp=True;
    }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','None'));
        options.add(new SelectOption('CA','Cease Address'));
        options.add(new SelectOption('CANADA','Canada'));
        options.add(new SelectOption('MEXICO','Mexico'));
        return options;
    }
    
}


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas​
This was selected as the best answer
srikanth cheera 11srikanth cheera 11
it has to display next to the dropdown(picklist)
Khan AnasKhan Anas (Salesforce Developers) 
Use this visualforce code:
 
<apex:page standardController="Account" extensions="TestC">
    <apex:form >
        
        <apex:sectionHeader Title="Address Details" />
        <apex:pageBlock Title="Select the type of Address">            
            
            <apex:outputLabel value="Address"/>                    
            <apex:selectList id="id_1" value="{!Account.Rating}" size="1" >
                <apex:actionSupport event="onchange" reRender="Container"/>
                <apex:selectOptions value="{!items}"/>
            </apex:selectList>                    
            &nbsp;&nbsp;
            <apex:outputPanel id="Container" >
                <apex:outputPanel id="ajaxrequest" rendered="{!Account.Rating!=''}" >
                    <apex:commandButton value="Continue"/>
                </apex:outputPanel>           
            </apex:outputPanel>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Regards,
Khan Anas