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
OlbrestOlbrest 

How I can use 'if' statement ?

Hello, Sirs.

I need to display input button when 'numofrecords' have value > 0.

I tried to used that code:

Code:
{!IF(numofrec > 0,'<input type="button" onclick="action();" value="Do something" class="btn"/>',"")} 

But result of this code not a button, but only text - '<input type="button" onclick="action();" value="Do something" class="btn"/>'

How I can fix it ?

Thank you, Gentlemen.


Message Edited by Olbrest on 01-20-2009 01:29 PM
VisualForceVisualForce

Hi...

        This is alternate solution

Use rendered attribute with <apex:commandbutton value="Do something" action="{!action}"/>

andresperezandresperez

Hi,

There are actually two ways to accomplish this.

First, using the rendered property of the command button. Since your action is a onclick javascript event, it could get messy trying to call the onclick without refreshing the page. You would have to do something like this:

<apex:outputPanel id="AJAXSection" />
<apex:commandButton value="Say hi..." onclick="alert('Hello world')" rerender="AJAXSection"

rendered="{!numRec>0}" />

your other option is to use the rerender method, but for an outputPanel...

<apex:outputPanel rendered="{!5>0}">
   <input type="button" onclick="action();" value="Do something" class="btn"/>
</apex:outputPanel>

 

Message Edited by andresperez on 01-21-2009 05:26 AM
Shannon HaleShannon Hale

You may also want to set the layout attribute to "none" for the outputPanel, if you find that the HTML span tags that it inserts by default interfere with your layout.

 

<apex:outputPanel rendered="{!5>0}" layout="none">
<input type="button" onclick="action();" value="Do something" class="btn"/>
</apex:outputPanel>