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
Jonathan Wolff 7Jonathan Wolff 7 

Display text insed of variable using renderer

Hello, I used an inputfield and wanted to display different texts depending on which value for the field "PDF_Vorlage__c" is inserted. But inseted of text I am only able to display the variable
( <apex:inputField value="{!Campaign.PDF_Vorlage__c}" rendered="{!IF(Campaign.PDF_Vorlage__c ='Vorlage 1' ,true,false)}"/>)

If I insert text in the value field I get an error.
Is it possible in some way to achive getting a text instead of the variable?
Best Answer chosen by Jonathan Wolff 7
SwethaSwetha (Salesforce Developers) 
HI Jon,
Assuming you don't want to use an extension class, you can add an ID to the inputfield and select it with Javascript.
<apex:page standardController="Campaign"  >
    <apex:form > 
        <apex:inputField value="{!Campaign.PDF_Vorlage__c}" rendered="{!IF(Campaign.PDF_Vorlage__c ='Vorlage 1' ,true,false)}"  id="Cmpvalue" />
        <script>
        document.querySelector('[id$=Cmpvalue]').value = 'This is the text i want to display';
        </script>
    </apex:form>
</apex:page>

In case you want to pass the value via controller, check https://salesforce.stackexchange.com/questions/92360/how-to-pass-apexinputfield-value-to-the-controller 

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you