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
Alex ShAlex Sh 

Display value in input text on VF page depending of dropdown value

Hi All, 
I have an input text on VF page. And I have a drop-down. If e.g. "Value1" is selected in drop-down then I need to type value to input text manually. But if "Value2" is selected then the value of  input text should be filled in automatically with some value. How can I do this second part?
Best Answer chosen by Alex Sh
Manish  ChoudhariManish Choudhari
Hi Alex,

You need to use "rerender"  on "onchange"  event of selectlist. For this you need to use "<apex:actionSupport>" tag. For ex.
<apex:selectList size=”1″ value=”{!country}”>
<apex:selectOptions value=”{!countries}”/>
<apex:actionSupport event="onchange" 
                                rerender="theTextInput" />

//Lets say  you have an inputText like below
//Above code will re render this inputttext and will show latest value of inputValue

<apex:inputText value="{!inputValue}" id="theTextInput"/>

The above code I have pasted is only for Visualforce. You need have an controller method name changeInputText which will modify the value of inputValue variable.

Please let me know if you need further help on this.