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
sairam namasairam nama 

i've a vf page which have a picklist with values 'YES' and 'NO' and a Proceedtopay command button if value is 'YES' then only the button has to visible .help me in this case....

Best Answer chosen by sairam nama
Sohan Raj GuptaSohan Raj Gupta
Hi Sairam,

You can use below code for your reference:
 
<apex:page controller="testController" >
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockSection >
                 <apex:outputPanel>
                  
                   <apex:selectList id="ddlOpt" multiselect="false" size="1" value="{!proceedYN}">
                       <apex:selectOption itemValue="Yes"></apex:selectOption>
                       <apex:selectOption itemValue="No"></apex:selectOption>
                       <apex:actionSupport event="onchange" reRender="btnProceed" status="status" action="{!checkProceedToPay}"/>
                   </apex:selectList>                  
                   
                   <apex:actionStatus id="status" startText="Loading..."/>
                   </apex:outputPanel>
              
              <apex:outputPanel id="btnProceed">
             
                  <apex:commandButton value="Proceed to Pay" rendered="{!isDisabled}"/>
                  </apex:outputPanel>
              
          </apex:pageBlockSection>
      </apex:pageBlock>
      
  </apex:form>
</apex:page>
 
public class testController{
    
    public boolean isDisabled {get;set;}
    public String proceedYN {get; set;}
    
    public testController(){
        isDisabled = true;
    }
    
    public void checkProceedToPay(){
        if(proceedYN=='Yes'){
            isDisabled = true;
        } else{
            isDisabled = false;
        }
    }
}

Hope this will help you.

Please let me know if it helped or you need any more assistance.

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta 

All Answers

Raja Y 14Raja Y 14
Hello Sairam,

Follow below piece of code . 
<apex:page standardController="Opportunity">
<apex:form >
    <apex:pageBlock id="pBlock" title="New Opportunity" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
            <apex:commandButton value="Won Notes" disabled="{!NOT(opportunity.StageName='Closed Won')}"/>
            <apex:actionStatus id="rStatus" startText="Refreshing..."/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1">
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Stage"/>
                <apex:actionRegion >
                <apex:inputField value="{!opportunity.StageName}">
                    <apex:actionSupport event="onchange" reRender="pBlock" status="rStatus"/>
                </apex:inputField>
            </apex:actionRegion>
            </apex:pageBlockSectionItem>
            <apex:inputField value="{!opportunity.Probability}"/>
            <apex:inputField value="{!opportunity.Name}"/>
            <apex:inputField value="{!opportunity.CloseDate}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>


Regards,
Raja.
Sohan Raj GuptaSohan Raj Gupta
Hi Sairam,

You can use below code for your reference:
 
<apex:page controller="testController" >
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockSection >
                 <apex:outputPanel>
                  
                   <apex:selectList id="ddlOpt" multiselect="false" size="1" value="{!proceedYN}">
                       <apex:selectOption itemValue="Yes"></apex:selectOption>
                       <apex:selectOption itemValue="No"></apex:selectOption>
                       <apex:actionSupport event="onchange" reRender="btnProceed" status="status" action="{!checkProceedToPay}"/>
                   </apex:selectList>                  
                   
                   <apex:actionStatus id="status" startText="Loading..."/>
                   </apex:outputPanel>
              
              <apex:outputPanel id="btnProceed">
             
                  <apex:commandButton value="Proceed to Pay" rendered="{!isDisabled}"/>
                  </apex:outputPanel>
              
          </apex:pageBlockSection>
      </apex:pageBlock>
      
  </apex:form>
</apex:page>
 
public class testController{
    
    public boolean isDisabled {get;set;}
    public String proceedYN {get; set;}
    
    public testController(){
        isDisabled = true;
    }
    
    public void checkProceedToPay(){
        if(proceedYN=='Yes'){
            isDisabled = true;
        } else{
            isDisabled = false;
        }
    }
}

Hope this will help you.

Please let me know if it helped or you need any more assistance.

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta 
This was selected as the best answer