function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jason Reed 63Jason Reed 63 

Display a rich text field after a checkbox is checked in visualforce

Trying to figure out how to display a Rich Tex Field after a checkbox is checked on a Visualforce page.
Hi Jason,

You can try the below approach.

1) Download the ckeditor standard package from this url
2)Go to Your Name –>Develop –> Static Resources and click ‘New.’ Upload the zip file and call it ‘CkEditor.’
3)Try the below code in your org.I have made use of my custom object api name and custom object field api name. You can change it according to your requirement.
<apex:page standardController="Job_Application__c" >
<apex:includescript value="{!URLFOR($Resource.CkEditor,'ckeditor/ckeditor.js')}" />
<script type="text/javascript">
function ReloadCKEditor() {
   for(name in CKEDITOR.instances)
       delete CKEDITOR.instances[name];

    <apex:form >
        <apex:pageBlock id="thePageBlock">
            <apex:actionRegion >
                <apex:pageBlockSection id="pbs1" title="Information" columns="2"> 
                    <apex:inputField value=" {!Job_Application__c.CheckboxTest__c}">// Here Job application is my custom object and Checbox test is the checkbox 
                        <apex:actionSupport event="onchange" reRender="thePageBlock"  oncomplete="ReloadCkEditor();"/>
                <apex:pageBlockSection title="Rich Text Box Section" id="Section" columns="2"  collapsible="false" rendered="{!Job_Application__c.CheckboxTest__c==true}"> 
                          <apex:inputTextarea value="{!Job_Application__c.Test_Richtext__c}"  styleClass="ckeditor" richText="false" />//This is the rich text box area which will be displayed when you check the checkbox
Below is the output:

User-added image

Let me know if it solves your problem.


Jason Reed 63Jason Reed 63
Thanks, I am trying to avoid using JavaScript and strictly Salesforce there another way?
Raj VakatiRaj Vakati
you can't  able to Rerender RTF after checkbox check ...
Hi Jason,

 The rich text area field will be initialised through JavaScript when the page is loaded, so without the using a script i am afraid if we would be able to achieve this functionality using Apex. Since rerender is not supported for Rich Text fields in Salesforce.

You can try using Flows once and see if you are able to meet the requirement.