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
carramrodcarramrod 

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.

 

kevinwukevinwu

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?

 

-Kevin