I'm having trouble figuring out how to properly rerender certain elements on a visualforce page and get them to update / populate other fields accordingly.
I have a lookup field that retrieves an account that can have multiple addresses; one of these addresses is a primary address. I then have a picklist of these addresses that should default to the primary, and finally, I have multiple text fields for the city, state, postal code, etc.
Upon selection of an account, the picklist should be populated with the primary address, as well as the various text fields. The user can then select another alternate address from the picklist, which will again change the various text fields.
Currently I have:
<apex:pageBlockSection columns="2" title="District Details" showHeader="true" collapsible="false"
id="DistrictDetails">
// this is the lookup field. after a value is selected, the selectList below should be updated
// *as well* as the text fields at the bottom with the primary address
<apex:inputField id="SchoolDistrict" value="{!Consultant_Request__c.Targeted_District__c}" required="false">
<apex:actionSupport event="onchange"
// should rerender/update both the select list AND text fields
// can only get one of these at a time to work, not both
rerender="AccountAddressesSelect, DistrictDetails"
focus="AccountAddressesSelect"
immediate="false"/>
</apex:inputField>
// this is the select list that contains all the addresses, should always default to primary
<apex:pageBlockSectionItem id="AccountAddressList">
<apex:outputLabel value="Account Addresses"></apex:outputLabel>
<apex:selectList size="1" id="AccountAddressesSelect" value="{!AccountAddress}">
<apex:selectOptions value="{!AccountAddresses}"/>
<apex:actionSupport event="onchange"
// action on controller that just sets text fields below
action="{!updateAddressFields}"
rerender="DistrictDetails"
focus="SiteAddress"/>
</apex:selectList>
</apex:pageBlockSectionItem>
// these should be populated by primary address after lookup field is selected, and also by any
// alternate addresses when selectList is selected
<apex:inputField id="SiteCity" value="{!Consultant_Request__c.Site_City__c}" required="true"/>
<apex:inputField id="SiteState" value="{!Consultant_Request__c.Site_State__c}" required="true"/>
<apex:inputField id="Country" value="{!Consultant_Request__c.Country__c}"/>
</apex:pageBlockSection>
I'm forgoing my Apex code because that's not the problem, I'm correctly populating the values of my lookups and selectlists, I just can't get the text fields to populate correctly.