+ Start a Discussion
abc0551abc0551 

Display multiselect picklist values in vf without semicolon

Hi All,

I have a multiselect picklist value in the vf page. Its a read only field. When I output the field the values appears with semicolon

 

Currently I am using the below code to ouput the field value

 <apex:outputText label="Franchises" value="{!Account.Franchises__c}"></apex:outputText>

and this displays the field values like below

Audi; Acura; Ford

My requirement here is i want to display the values without the semicolons. Can i display each value in a different line?

Eg: Audi

      Acura

     Ford

how can i do this?

asish1989asish1989

Hi

  will you check this...

<apex:page controller="FtestDsplyMultiSelectController">
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockSection columns="1">
                <apex:outputField value="{!account.TestMultiSelect__c}"/> <br/>
                <apex:repeat value="{!finalString}" var="a">
                    {!a} <br/>
                </apex:repeat>
               
            </apex:pageBlockSection>    
            
        </apex:pageBlock>
    </apex:form>
 </apex:page>   
my controller is...


public class FtestDsplyMultiSelectController {
    public Account account{get;set;}
    public String newString{get;set;}
    public List<String> finalString{get;set;}
    List<String> urlParam = new List<String>(); 
    public FtestDsplyMultiSelectController() {
        account = [SELECT id, Name,TestMultiSelect__c FROM Account WHERE id =:'0019000000G0HJR'];
        newString = account.TestMultiSelect__c;
        finalString = new List<String>();
        List<String> urlParam = newString.split(';');
        for(integer i =0; i<urlParam.Size(); i++){
           
            finalString.add(urlParam[i]+'\n');
        }   
       System.debug('###############FINALSTRING############'+finalString) ; 
    }
    public List<String> getFinalString(){
        return finalString;
        
    }    
 }   

 Did this post answers your question if so please mark it solved so that others get benifited

 

Thanks

asish

RuYveRuYve

Hello,

Can you try this...., It works in my visualforce page

 

<apex:outputText escape="false" value="{!SUBSTITUTE(Account.TestMultiSelect__c,';','<br/>')}"/>

Mhlangano KhumaloMhlangano Khumalo
@RuYve Thank you so much, I had the same problem and your solution worked. :)