[SalesForce] Comma separated values in visual-force page using query or java-script

I have a field which displays values in visualforce Page as follows "a;b;c;d" i want the values to displayed as comma separated values as "a,b,c"

I using a repeat tag inside which i have field

{!a.test}

I do have pagination and its displaying in the initial page as "a,b,c" and when i clicking on next it is displaying nothing i am using the below javascript.

var tList="{!a.test}";
tList = tList.substring(0, tList.length - 1);
var tSplit=tList.split(';');
var TypeDis='';
for(var x=0;x<tSplit.length;x++){
TypeDis+=tSplit[x]+', ';
}
TypeDis = TypeDis.substring(0, TypeDis.length - 2);
$('#i{!a.id}{!ROUND(i,0)}').html(TypeDis);

Best Answer

You need to use a function SUBSTITUTE:

<apex:outputText value="{!SUBSTITUTE(a.test ,';',',')}" />

This function substitutes new text for old text in a text string. See the docs here.

Related Topic