Activity Forums Salesforce® Discussions how to set Button enable and disable mode Reply To: how to set Button enable and disable mode

  • Shubham

    Member
    August 29, 2017 at 8:03 am

    Hello Uday

    ****Controller****

    public class sampleCon {
    public String selectedImage{get;set;}

    public sampleCon(){
    selectedImage = '';
    }
    public PageReference test() {
    return null;
    }

    public List<SelectOption> getItems() {
    List<SelectOption> Images = new List<SelectOption>();
    Images.add(new SelectOption('hyd','hyd'));
    Images.add(new SelectOption('che','che'));
    Images.add(new SelectOption('bng','bng'));
    return Images;
    }

    public String getImage() {
    return selectedImage;
    }

    public void setImage(String selectedImage) {
    this.selectedImage = selectedImage;
    }
    }

    ****VisualForcePage****

    <apex:page controller="sampleCon">
    <apex:form>
    <apex:selectList value="{!selectedImage}" multiselect="true">
    <apex:selectOptions value="{!Items}"/>
    </apex:selectList><p/>
    <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    </apex:form>
    <apex:outputPanel id="out">
    <apex:actionstatus id="status" startText="testing...">
    <apex:facet name="stop">
    <apex:form>
    <apex:commandButton value="Submit" disabled="{!If(selectedImage == '',True,False)}"/>
    </apex:form>
    </apex:facet>
    </apex:actionstatus>
    </apex:outputPanel>

    </apex:page>