1

Right now I have a vf page that shows like this:

<div class="col-md-5">
  <input id="contactFirstName" type="text"  class="form-control" name="userFirstName" maxlength=40 value="{!contact.firstName1}" />
</div>

But now I want show another field firstName2 if that filed is not blank instead of firstName1, but if firstName2 is blank I still wanna show firstName1.

So how should I do this?

Like {!contact.firstName2}?{!contact.firstName2}:{!contact.firstName1}

Any help will be appreciated!!!

1

Following code should work. just replace the firstName & lastname field with appropriate fields

<apex:page standardController="contact">
    <div class="col-md-5">
      <input id="contactFirstName" type="text"  class="form-control" name="userFirstName" maxlength="40" value="{! IF(contact.firstName != '' , contact.firstName , contact.lastname)}" />
    </div>
</apex:page>
1
  • Thank you, it works fine
    – Ben
    Feb 20 '20 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.