+ Start a Discussion

Dynamically populating Text Box based on changes to a picklist Visualforce

In visualforce i'm using a picklist for the user to select an office location.

When a user changes the value in the picklist, i'd like it to populate a textbox with a default address.


I've done this before in ASP.net and javascript but don't know how to approach it in apex/vf.

If possible i'd like to not store the values in the custom controller, but in the apex code itself, the reason being if there's a change in address, it's as easy as changing the visualforce page.

thanks in advance.



What you could do is use an actionRegion and actionSupport to detect an onchange event in your picklist. Then you can put a bunch of outputTexts inside of an outputPanel which will be rerendered after onchange.


These outputTexts can just output properties (such as address) which are set by a method in your controller. This is the method that is used by the AJAX call.


Does this help?