I'm trying to get the value of selected list and passing it to the controller but my code does not work ! I have tried to do this.
<apex:selectList value="{!facility}" size="1">
<apex:selectOptions value="{!FacilityOptions}" />
<apex:actionSupport event="onchange">
<apex:param name="selectedVal" value="{!facility.Name__c}" assignTo="{!facilityName}"/>
</apex:actionSupport>
</apex:selectList>
Controller:
public List<Facility__c> facilities {set; get;}
public Facility__c facility {get;set;}
public List<SelectOption> getFacilityOptions() {
List<SelectOption> options = new List<SelectOption>();
for (Facility__c record : getfacilities())
{
options.add(new SelectOption(record.Name,record.Name__c));
}
return options;
}
public List<Facility__c> getfacilities(){
facilities = [SELECT Name,Name__c FROM Facility__c];
return facilities;
}
value
parameter when the page is submitted. Can you post your controller code? At least the portions dealing withfacility
andFacilityOptions
. Without that I can't provide a more precise answer. Also, are you simply trying to pass this value back when the form is submitted, or do you need invoke a controller behavior each time the selectList changes?