Salesforce | document.getElementById(‘id’).value not working for apex:outputtext

|
| By Webner

If you have an apex:outputtext and you try to get its value in Javascript using document.getElementById(‘id of outputtext’).value(), that won’t work. The reason is apex:outputtext is translated to HTML SPAN element.

So

<apex:outputtext value=”Amount” id=”amntId”/>

becomes

<span id="amtId">Amount</span>

So to get the value use innerHTML instead – document.getElementById(‘id of outputtext’).innerHTML.

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 salesforce@webners.com

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *