Hi Friends, In this tutorial, I am going to show you how you can set value dynamically in the custom label from a visualforce page. There is no external JS library has been used in this example. Whole functionality is handled at the client side with no apex code. So without wasting time let's get started,

Passing value in the custom label

Step 1: Login to your Salesforce Org. and navigate to Setup | Create | Custom Labels and click on "New Custom Label" button.


Step 2: Fill all required information just like the below image and hit the "Save" button.

In the above image, you can see "Hello {0} {1}" in value. Here "{0} {1}" is the position where you will set value from the visualforce page with the help of <apex:param> tag.

Step 3: Open developer console, Navigate to File New | Visualforce Page and create a new visualforce page called PassValueInCustomLabel and replace the following markup.

PassValueInCustomLabel.vfp
 <apex:page sidebar="false">
    <apex:form id="frm">        
        <h1>            
            <apex:outputText value="{!$label.SetvaluefromVFpage}">
                <apex:param value="{!$user.FirstName}" />
                <apex:param value="{!$user.LastName}" />
            </apex:outputText>
        </h1>
    </apex:form>
 </apex:page>
Step 4: Preview the visualforce page to see the outcome.

Output:

See also:

Conclusion:
Hope you like this tutorial, for any query or suggestions please feel free to comment.
Thank you.