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
Ravi23Ravi23 

Multipicklist value selection to open a text box below

Hi All,

         Can you please guide me in the scenario below.

I have a multipicklist field where one option is other. If I select the other option(in multipicklist) then a text box should open below to enter what that other is. Can some one guide me on this
Swayam@SalesforceGuySwayam@SalesforceGuy
You can use dependent field, Go through below link

https://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_dependencies.htm&language=en_US

Hope this help,

-
Thanks,
Swayam
@salesforceguy
Ravi23Ravi23
Hi Swayam,

                    Not in config way. I am looking at the code level if you have any idea can you guide. Or anyone who knows this issue can they guide me?
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

The you have to use partial page refresh, below are the step


1.  In you text field use a boolean variable for rendered
2. Use action support on you picklist, event onchange call Apex method which will set Step 1 variable to true on value other and use rerender for partial page refresh.

Hope this helps,

--
Thanks,
Swayam
@salesforceguy
Gyanender SinghGyanender Singh
Hi Ravi,
You can do the same thing by two ways:
1) By using class in this use two boolean variable and in first one renderd false and after that rerender the field which you want to show.
2) By using javascript on the vf page and in this you have no need to use controller , please try the below code and let me know this is the solution of your problem.
<apex:page standardController="Account" >
<script>
    function show(){        
        var select = document.getElementById('{!$Component.theform.theinputField}');
        var selected = [ ];
        var flag = false;
        for (var i = 0; i < select.length; i++) {
            if (select.options[i].selected){
                selected.push(select.options[i].value);
                if(select.options[i].value=='Other'){
                    flag = true;
                }
           }
        }
        if(flag){
            document.getElementById('{!$Component.theform.theinputtext}').style.display='Inline';
        }
        else{
            document.getElementById('{!$Component.theform.theinputtext}').style.display='none';
        }
   }
</script>
    <Apex:form id="theform">
        <apex:inputtext value="{!account.Send_Email__c}" id="theinputtext" style="display:none"/>
        
        <apex:inputField value="{!account.Test_Multipicklist__c}" onchange="show()" id="theinputField"/>
    </Apex:form>
</apex:page>

Thanks
Gyani