how do i add conditional statements to custom forms?
Form fields can be displayed conditionally. This is particularly helpful when using pull-down menus, check-boxes, or radio buttons to conditionally display other fields. To conditionally display a field, type the exact value from the unique ID column followed by an "=" sign and then the exact value it must equal in the show if column.
STEP 1: Add a new field.
Click on the text box to display a list of types of fields. Then click the green plus sign to add the field. (Figure 1)
STEP 2: Define your conditional statement.
Conditional statements use operators to define how a field should be displayed. Operators are:
- (=): equals
- (&&): and (takes precedence over ||)
- (||): or
For example, if you are creating a new field that should only be shown if the field with unique ID "species" equal "mouse", you should type "species=mouse" in the show if field. Note that for show if statements to work properly, each unique ID value must be different within one form and must be entered in the show if field exactly as it displays in the unique ID field.
Show this field if species is equal to mouse.
Show this field if species equals mouse AND color equals white.
Show this field if species equals mouse and color equals white OR if species equals mouse and color equals brown.
STEP 3: Save and review.
When you have finished adding your conditional fields, click the Save button. Then review your fields in the form. (Figure 2)
Was this article helpful?