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
Michael SchellMichael Schell 

If else statement on checkbox field

I have a VF page where I need to do an if else. Basically there is a checkbox on my object, if its checked i want to reference a new field i've created, if it's not checked I wanted to reference the field {!rfp.Order__r.Customer__r.Name}, as seen below. Any help is appreciated, new to the game. 

Code on VF page: 
This letter will serve as our engagement of your services to prepare an appraisal of the property referenced above and described in the attached addendum (together, the “Agreement”). </p> <p> Your engagement is as an independent contractor and not as an employee or agent of {!rfp.Order__r.Customer__r.Name}. </p>
 
Lars NielsenLars Nielsen
One way to handle this Michael is jut have two output fields next to eachother and then use the third field you are talking about to decide which one should be rendered visible on the screen. Here is a crude example below using Accounts with just the standard account controller.
 
<apex:page standardController="Account">

Use the number below to refer to account:
<apex:outputText id="field1" value="{!account.BillingPostalCode}" rendered="{!account.Match_Billing_Address__c = true}"/>
<apex:outputText id="field2" value="{!account.ShippingPostalCode}" rendered="{!account.Match_Billing_Address__c = false}"/>
Please call if you have any quesitons.


</apex:page>

 
Lars NielsenLars Nielsen
In the case above, I am just showing one of the zip codes based on a boolean flag on the account. 
AmrenderAmrender
Use the code below
 
<apex:page standardController="Account">

<apex:outputField value="{!account.FieldA}" rendered="{!account.CheckBox Field}"/> //will be rendered when checkbox is checked.
<apex:outputField value="{!account.FieldB}" rendered="!{!account.CheckBox Field}"/> //will be rendered when checkbox is unchecked.

</apex:page>

Regards
Amrender