You need to sign in to do that
Don't have an account?
sehoop27
Text field dependent on pick list field - VisualForce help needed
I have seen that a number of people have experienced my issue of wanting to have a text field dependent on a pick list field -- meaning that if a certain value was selected in a pick list, then the text field would require data entry. (e.g. if user selects 'Other', then user must complete Comments field).
I do not want to manage this via field validation that occurs when the record is saved. I would also prefer not to achieve this with an S-control. I'm thinking that this is best achieved with VisualForce.
Ideally, I would like for the text field (i.e. Comments field) to display upon selection of the 'Other' pick list value. (IT would remain hidden if the 'Other' pick list value was not selected.)
I believe that this is done with a partial page refresh. I am looking for help in the form of a simple example of house this would be coded in a VisualForce page.
Thanks,
Scott
Please mark Best answer, if you will find it correct.
<pre>
<apex:page standardController="Account" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pagemessages />
<apex:pageBlockSection id="pm" columns="1" title="Dependent Text">
<apex:inputField value="{!Account.Picklist_Field__c}">
<apex:actionSupport event="onchange" rerender="pm" />
</apex:inputField>
<apex:inputField value="{!Account.Comments__c}" rendered="{!Account.Picklist_Field__c=='Other'}" />
<apex:pageBlockSectionItem rendered="{!Account.Picklist_Field__c!='Other'}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
</pre>
This should show the Comments field when the picklist is 'Other' and show a blank space when it is anything else.
Yeah you are right. PageblockSectionItem is more useful than panel grid. I already implemented this and its work fine. I have one picklist field "Current_Status__c". If Current Status == "In Project", one dependent text field will appear i.e. TL_PM_Name__c.
Here is my code: