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

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;
  }
}
| improve this answer | |
  • yep, I've created action methods in controller named void nop() {} for this very purpose – cropredy Oct 10 at 23:44
  • I have put the action methods but this method is not getting called. – SFDC 44 Oct 11 at 10:02
  • Did you get it working? – GotStu Oct 21 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.