A 'choice field' on a form gives the user the ability to choose one or more items from a list of choices. If the choice field is a radio button, then the user can only make one choice. If the choice field is a checkbox list, then the user can select one or more items.
In your templates you may want to include content, or exclude content, based on the user’s choice on the form. You do this using either the 'Like' operator or the '=' operator. Which one you use will depend on the type of choice field that has been used on the form.
Possible multiple selections – checkbox lists – 'Like'
If the user has the ability to select more than one item in the choice field, then you need to use the 'Like' operator.
The 'Like' operator basically asks the question 'Is the following text included in within the choices selected?'
The syntax for the Like operator is as follows:
{ MERGEFIELD IfStart:1 Field_cho Like '%Expression%' }
This will test to see if the 'Expression' has been selected within the choice field 'Field_cho'.
You must use the 'Like' operator with the '% %' quotes around the Expression when testing to see if one or more choices have been selected in a checkbox group.
The reason for this is that the data file will contain the choices separated by a comma, i.e. 'Choice1,Choice2,etc'. The quotes '% %' basically say, ignore everything either side of the expression that we are testing for. So in this case '%Choice2%' would search for the expression '%Choice2%' and would ignore the Choice1,…,etc either side of the expression.
Testing if a choice has NOT been made – 'Not Like'
You can also test to see if the user has not selected a particular item within a choice control using the 'Not Like' operator.
The syntax is:
{ MERGEFIELD IfStart:1 Field_cho Not Like '%Expression%' }
You use the Not Like operator when the user has the ability to select one or more items from a choice field, ie. a checkbox list.
So in this case we are asking the question, has the user NOT selected 'Expression' from the list of choices.
Only one selected item – radio buttons
You can use the '=' (equals) operator if the user is only able to select a single item from the range of choices, i.e. if the form field is a radio button or drop-down list. This is because only one Expression can be selected.
For example:
{ MERGEFIELD IfStart:1 Field_rdo = 'Expression' }
In this case you do not need to use the '% %' quotes, because the data will only contain one choice, and will not include any commas or other data.
This also works for checkbox groups which allow multiple selections, but only if that choice is the only one selected.
Testing if a choice has NOT been made – '<>'
If the user can only make one selection and you want to test whether that selection has NOT been made, i.e. some other item has been selected, then you can use the '<>' (or 'not equals') operator.
The syntax is:
{ MERGEFIELD IfStart:1 Field_cho <> 'Expression' }
Comments
0 comments
Article is closed for comments.