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
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com 

Use of onchange componenet on apex:selectlist!!!Plz help

Hi All,

   I have this piece of code here, given below:

 

     <apex:pageBlock id="tEntryWeekSelectionPageBlock">
         <apex:actionRegion >  
         <apex:pageBlockSection id="selectedWeek" title="Project List for {!$User.FirstName} {!$User.LastName}" columns="2" collapsible="true">
              <apex:pageBlockSectionItem id="selectedWeek">
              <apex:outputLabel for="selectedWeek">Week Beginning</apex:outputLabel>
                  <apex:panelGroup >
                  <apex:selectList value="{!selectedWeek}" multiselect="false" size="1">
                      <apex:selectOptions value="{!Weeks}"/>
                  </apex:selectList>  
                 </apex:panelGroup>
              </apex:pageBlockSectionItem>
              <apex:commandButton value="Go"  action="{!setWeek}" rerender="timeEntryBlock, messageBlock"/>
        </apex:pageBlockSection>
        </apex:actionRegion>  
        </apex:pageBlock>

 

Now the action="{!setWeek}" is working perfectly on click of the button. But now I want to perform the same action on change of value in my apex:selectList value="{!selectedWeek}", when I make the given change to my code , it throws an error.

  <apex:selectList value="{!selectedWeek}" multiselect="false" size="1" onchange="!{setWeek}">

Can anyone please help  me with this?

asish1989asish1989

Hi

Try in this way 

 

<apex:selectList value="{!selectedWeek}" multiselect="false" size="1">

         <apex:actionSupport event="onchange" action="{!setWeek}" reRender="timeEntryBlock, messageBlock"/>
                      <apex:selectOptions value="{!Weeks}"/>
                  </apex:selectList>  

If this post answers your questions please mark it as solved and give kudos for this post If It helps you

 

Thanks

DuffAlthausDuffAlthaus
Thanks asish1989.  Worked great.