Salesforce | Using Javascript to set value in parent Visualforce page field

| By Webner

Suppose you have a Visualforce page with a form and you have a link to open a popup. The page loaded in popup needs to set a value back into a textbox in the parent page. Here is how you can achieve this:

This is sample code of the parent Visualforce page:

<apex:page standardController=" ">
<apex:form id="theForm">
<apex:pageBlock id="thePageBlock">
<apex:pageblockSection id="theSection">
<apex:inputfield value=" ” id="Namefield"/>
<apex:pageblockButtons >
<apex:commandButton onclick="'/apex/page2?name={!$Component.theForm.thePageBlock.theSection.Namefield}’);”/>

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Salesforce customization, App development or any other software development assistance please contact us at