Getting richTextAreaSHowValue & richTextAreaSHowValue1 as null", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4TiBSAV", "datePublished": "2018-04-02T07:38:57.000Z", "author": { "@type": "Person", "name": "Suyog Shirsikar", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DDOSPQA5", "affiliation": { "@type": "Organization", "name": "ACCENTURE" } } } ] } }
Skip to main content
I am trying to get id of the field in javscript like this :

var getRichTextId=document.getElementById('{!$Component.theForm.richTextArea}');  or 

 var getRichTextId= document.getElementById(richTextArea);

and the field on the same  VF page for getting id is :

 <apex:inputtextarea  id="richTextArea" richtext="true" cols="100" rows="15"/> .

But in both cases i am getting value of "getRichTextId" as null.How to get that.I want to copy some data into that field after getting id.
4 answers
  1. Apr 2, 2018, 7:38 AM
    <apex:page controller="i20TemplateApex">  

    <apex:form id="theForm">

        <script>    

        function getIdOfFields(){       

           

            var richTextAreaSHowValue = document.getElementById('richTextArea');

            console.log('richTextAreaSHowValue='+richTextAreaSHowValue);  

            richTextAreaSHowValue.value=inputValue;

            

            var richTextAreaSHowValue1 = document.getElementById('{!$Component.theForm.richTextArea}');

            console.log('richTextAreaSHowValue1='+richTextAreaSHowValue1);  

            richTextAreaSHowValue1.value=inputValue;            

        } 

        </script>

        <apex:pageBlock title="Select Object and Fields" id="pageBlockId">

         <apex:pageBlockSection title="Select an Object" columns="1">

        <apex:pageBlockSectionItem id="pbsRichtextArea" >                        

                        <apex:inputtextarea label="RichText" id="richTextArea"  richtext="true" cols="100" rows="15"/> 

                           <apex:commandButton value="Insert Field" id="insertFieldButton" onclick="getIdOfFields()"/>                        

                    </apex:pageBlockSectionItem>

                    </apex:pageBlockSection>

                     </apex:pageBlock>

    </apex:form>

    </apex:page>

    Getting richTextAreaSHowValue & richTextAreaSHowValue1 as null
0/9000