0

Selectlist value is not binding to the controller variable while changing selectoption.

 <td role="gridcell" style="white-space:unset;text-align:left;display:{!IF( selectId=="Term Wise" ||selectId=="Month Wise" || selectId=="Week Wise" || selectId=="Day Wise",'table-cell','none')}">
                                <div class="slds-select_container">
                                    <apex:selectList value="{!termid1}" multiselect="false"  styleClass="slds-select slds-form-element__control"  size="1">
                                        
                                        <apex:selectOptions value="{!TermList1}" />
                                        <apex:actionSupport event="onchange" reRender="sh"/>
                              </apex:selectList>  
                             </div>

Please help!

1 Answer 1

1

Please see below working code and compare with your own to see what is missing.

Page

<apex:page controller="exampleCon"> 
    <apex:form> 
      <apex:outputpanel id="counter">
        <apex:outputText value="Counter = {!count}"/>
        <apex:selectList value="{!countString}" multiselect="false" size="1">
                  <apex:selectOptions value="{!theValues}" />
                  <apex:actionSupport event="onchange" action="{!incrementCounter}" reRender="counter" status="counterStatus"/>
        </apex:selectList> 
      </apex:outputpanel>
      <apex:actionStatus id="counterStatus" 
                          startText=" (incrementing...)" 
                          stopText=" (done)"/>
    </apex:form>
</apex:page>

and Apex

public class exampleCon {

  public Integer count {get; set;}
  public String countString {get{return String.valueOf(count);} set;}
  public List<SelectOption> theValues {get;set;}
           
  public exampleCon() {
    count = -1;
    theValues = new List<SelectOption>();
    theValues.Add(new SelectOption('-1' , 'Select'));
    theValues.Add(new SelectOption('0' , 'Yes'));
    theValues.Add(new SelectOption('1' , 'No'));
  }

  public void incrementCounter() {
          count++;
  }
                  
  public Integer getCount() {
      return count;
  }
}
3
  • yep, I've created action methods in controller named void nop() {} for this very purpose
    – cropredy
    Oct 10, 2020 at 23:44
  • I have put the action methods but this method is not getting called.
    – SFDC 44
    Oct 11, 2020 at 10:02
  • Did you get it working?
    – GotStu
    Oct 21, 2020 at 2:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .