--- So in summary, I just want the second field ot be populated with the text from the first field after it's populated. Thanks, Thomas", "answerCount": 1, "upvoteCount": 0, "datePublished": "2018-07-16T17:25:53.000Z", "author": { "@type": "Person", "name": "Thomas Reinman", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DDnNQQA1", "affiliation": { "@type": "Organization", "name": "Salesforce" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "Nevermind this thread -- can be closed. Using JQuery to rerender on the client side.  Thanks to Bob Buzzard (as usual)! https://developer.salesforce.com/forums/?id=906F0000000AahBIAS", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4042SAB", "datePublished": "2018-07-16T20:46:45.000Z", "author": { "@type": "Person", "name": "Thomas Reinman", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DDnNQQA1", "affiliation": { "@type": "Organization", "name": "Salesforce" } } } ] } } Skip to main content

Hello,

I'm trying to set the value of a text field to the value of another field after an 'onchange' event. I've decided to take the JavaScript approach rather than an using actionSupport because this should be a quick update. 

Here is the Visualforce part:

<apex:pageBlockSection title="Account & Contact Details" collapsible="false">

Please locate the existing Account: <div style="text-align: center;">

<apex:inputField value="{!Lead.Account__c}" id="account" onchange="updateCompanyName()"> </apex:inputField> </div>

<div style="text-align: center;"> <apex:inputField value="{!Lead.Company}" id="company"></apex:inputField> </div>

-----------

Here's the function:

<script type="text/javascript"> function updateCompanyName(){

var accountName = Document.getElementById('{!$Component.account}').value;

ar companyName = Document.getElementById('{!$Component.company}').value;

companyName.value = accountName.value; }

</script>

---

So in summary, I just want the second field ot be populated with the text from the first field after it's populated. 

Thanks,

Thomas
1 answer
0/9000