Writing an If then statement off a pick list

Hello, I am wondering how to write a pick list that then sets the picked item as a variable that then triggers a specific if statement.

Hi Geoff!

How is something like this?

{formmenu: default=15; 25; 35; name=count}

Number of units: {=count}

{if: count < 20}This is less than 20.{elseif: count > 20 AND count < 30}This is more than 20. {elseif: count >30}This is more than 30.{endif}

This works great for the pick list, thank you!
Is the structure a little different if I want a pick list that is "pick multiple".
For instance if picking option 1, 2, or 3.
What if the user picks option 1 and 3.
I want my out put to be
1 (text)
2 (text)

Sure, if you want to make the drop-down menu multiple, the format will have to change slightly.

Here's an example:

{formmenu: Choice A; Choice B; Choice C; name=options; multiple=yes}

Options:
{choices=join(options, "
")}{=choices}

{if: contains(choices, "Choice A")}Choice A is selected.
{endif}{if: contains(choices, "Choice B")}Choice B is selected.
{endif}{if: contains(choices, "Choice C")}Choice C is selected.{endif}

Exactly what I needed, thank you!
How do you control the dead space after the if statements?
I know theres the trim function but it either buds the previous if statement next to the other or it leaves dead space.

1 Like

Hi Geoff!

You can use the trim setting to reduce whitespace in snippets. In the example above, you can add a trim setting to the {endif} buttons to reduce space after the if statements.

Here's a guide we wrote on how to clean up whitespace in snippets:

If you have any questions, please let me know.