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
skyfall007skyfall007 

IF () on VF Page

Hi,

 

How to use something like this..

 

<td >

          <apex:outputText value="{0, number, $###,###,###,##0.00}">
                    <apex:param value="{!IF(list.size>1,list[1].FieldValue,'$0.00')}"/>
          </apex:outputText>

</td>

 

Thanks

hemantgarghemantgarg

IF() is looking okay, but I think list[1].FieldValue does not work on visualforce , you need to do it in some other way.

asish1989asish1989

Hi 

 you can use If condition in apex:param...

here is some sample of code you can refer...

I have designed a page..which shows Account Type and Account Industry Filed.when you choose "Other" then helooo will appear..or when you choose "Industry " from Account Industry field then helo check will apear...

I am passing one parameter for those two things by using If condition..

Here is my page...

<apex:page controller="Mycontrollernew">
     <script type="text/javascript">
  function Callmefunc(id)
   {
   alert(''+id); 
   var type = document.getElementById(id).value;
   alert(type);
   alert('hi');
    
    check(type); 
    //return true;
    
   
   }
   </script>
    <apex:form >
    <apex:actionFunction name="check" action="{!makingfield}" reRender="refresh">
                    <apex:param name="Mahavir" value="{!(if(account.Type != NULL , account.Type,account.Industry))}" />
                </apex:actionFunction>
        
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:inputField value="{!account.Type}" id="check" onchange="Callmefunc('{!$Component.check}');"/>
            <apex:inputField value="{!account.Industry}" id="check1" onchange="Callmefunc('{!$Component.check1}');"/>   
            
           
        </apex:pageBlockSection>
        <apex:outputPanel id="refresh" >
        <apex:outputPanel rendered="{!readonly=='true'}" >
              helooooo
            </apex:outputPanel> 
            <apex:outputPanel rendered="{!readonly2=='true'}" >
                helo check
            </apex:outputPanel> 
            </apex:outputPanel> 
    </apex:pageBlock>
    
     </apex:form>
 </apex:page>

 Here is my controller..

public class Mycontrollernew {
     public Account account{get;set;}
     public String act{get;set;}
     public String readonly {get;set;}
     public String readonly2 {get;set;}
     public Mycontrollernew(){
     }
     
     public void makingfield() {
        act =System.currentPageReference().getParameters().get('Mahavir');
        System.debug('!!!!!!!!!!!!!!!!!!!asish!!!!!!!!!!!!!LeadType!!!!!!!!!!!!!!!!!'+act);
        if(act=='Other') {
          readonly = 'true';
        }
        else if(act=='Engineering'){
            readonly2 = 'true';
        }    
    }
 }

 DId this post answers your questions if so please mark it solved.

 

 

     Thanks