The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Challenging Conditional Statement


This Discussion is public


I have a field that can contain one of three values:

  1. T
  2. NC
  3. a number greater than zero

I'd like to display either Trace (T), NH or the number as X CM.  For example: Trace, NC or 10 CM.

Something like this, although it won't work since I'm using the same parameter in the same statement.

[if 38 equals="T" ]Trace[/if 38] [if 38 equals="NC" ]NC[/if 38][if 38 not_equal="T" and not_equal="NC"  ] [38] CM[/if 38]

I went down the path of nested statements but that was a dead end since I'm using the same field it seems.




You haven't given enough detail.

What type of field? Is this a text field, a radio button, or a dropdown?

Where are you using the conditional code? COnditional logic? Dynamic value calculation? In a view, perhaps?

Please provide more detail about what you are trying to accomplish.


This is a text field that uses regex to limit answers. The user can enter in the the following values:

any positive number up to 99

Then, I'm displaying the field in a view. This is an example for the field with the ID if 242:

[if 242 equals="T" ]Trace[/if 242] [if 242 not_equal="T"   ] [242] CM[/if 242]

The above works for T and CM so "Trace" will display when the value is "T" and "CM" will display along with the number value when the field is a number. However, at the moment if the value is "NC" then "NC CM" displays.

What I need is something like this.

[If 242 equals "T"] Trace
[elseif 242 equals "CN"] CN
[else ] [242]CM [ /if 242]





I don't think you'll find a conditional that will work with this. Unless you make sure you save the correct values to the database when the entry is created, you're going to have to use jQuery to display the values when the view loads.

In order to this, you have to provide a unique identifier to each of the items displayed in the view. You can do this by wrapping each field in a div with an id. For example,

<div id="field_xxxxx_[id]">[242]</div>

The xxxxx above should be the field's key. The ID is the record's entry ID. Once you have an identifier you can grab onto, you can change the HTML or text of div.

The idea is to loop through all elements that start with field_xxxxx_ and use the $(this) object to evaluate the current html content. Use a switch or nested if statement to define the new text and change the html content of the div with the new value.

The simpler solution would be to just save the correct values. You can adjust field values before the form entry is created by hooking into frm_pre_create_entry:

Since you are using regex to only accept T, NC and numbers from 1 to 100 (i.e. no decimal places), you might be able to get away with the following:

[if 242 equals="T"]Trace[/if 242]
[if 242 equals="NC"]NC[/if 242]
[if 242 greater_than="0" less_than="100"][242]CM[/if 242]


That worked great! Thanks!

would this not work for you also?

Check if value is not equal to several values#

Use this to check if a field value is not equal to several values. Use [if x not_equal_multiple="value1,value2,value3"]content here[/if x] in your View or email message.
add_filter('frmpro_fields_replace_shortcodes', 'frm_not_equal_to_multiple_values', 10, 4);
function frm_not_equal_to_multiple_values( $replace_with, $tag, $atts, $field ) {
if ( isset ( $atts['not_equal_multiple'] ) ) {
$check_values = explode( ',', $atts['not_equal_multiple'] );
foreach ( $check_values as $check_value ) {
if ( $replace_with == $check_value ) {
$replace_with = '';
return $replace_with;

Discussion closed.