Adding in dynamic custom commands with drop down lists

I want to build a drop down list with an option of "other". I can't figure out how to create a custom option of a free text box that we can type into once "other" is selected. Can anyone please assist? I have tried watching tutorials and they don't have what I am looking for.

1 Like

Hey Jennifer,
Welcome to Text Blaze Community.
You can use with {if} to render a text field when other is selected and ternary operator to select final output to switch between dropdown and text field. Here is an example.

{note: preview=yes}{formmenu: Choice A; default=Choice B; Choice C; other; name=selection}{if: selection=="other"}{formtext: name=other}{endif}{finalSelection=other if selection == "other" else selection}{endnote}
You have selected: {=finalSelection}

1 Like

@Jennifer_Zoucha

In addition to @VinodGubbala's example, you can also use this with a multi-select menu:

{note}
Suggested actions: {formmenu: name=choice; Restart your computer.; Uninstall and reinstall the software.; Threaten your computer with a baseball bat.; other; multiple=yes}
{if: contains(choice, "other"); trim=right}
Customized choice: {formtext: name=other}
{endif}
{endnote: trim=right}

Please follow these steps:
{=join(replace(choice, "other", other), "\n")}

2 Likes

@Cedric_Debono_Blaze Related to above...what would I need to change in my snippet (besides switching multiple on) to replicate the section under "please follow these steps"?

Thanks!

{note}
Select a Home: {formmenu: default=Home 1; Home 2; Home 3; Home 4; Home 5; Home 6; name=option; multiple=no}

{endnote: trim=right}

{if: option=="Home 1"}{import: \h}{elseif: option=="Home 2"}{import: /h2}{elseif: option=="Home 3"}{import: /h3}{elseif: option=="Home 4"}{import: /h4}{elseif: option=="Home 5"}{import: /h5}{elseif: option=="Home 6"}{import: /h6}{endif}

Hi @Justin_Guerra ,
Do you mean that you'd like to import multiple snippets based on the selection, instead of just one?

Hey @Dan_Barak1. I am trying to be able to select multiple options from the dropdown and have the imported snippets all appear.

Try this (also notice how I set up the IFs and the trimming to avoid whitespace)

{note}
Select a Home: {formmenu: default=Home 1; Home 2; Home 3; Home 4; Home 5; Home 6; name=option; multiple=yes}

{endnote: trim=right}

{if: contains(option,"Home 1")}{import: \h}{endif}{if: contains(option,"Home 2"); trim=left}
{import: /h2}{endif}{if: contains(option,"Home 3"); trim=left}
{import: /h3}{endif}{if: contains(option,"Home 4"); trim=left}
{import: /h4}{endif}{if: contains(option,"Home 5"); trim=left}
{import: /h5}{endif}{if: contains(option,"Home 6"); trim=left}
{import: /h6}{endif}

2 Likes

Thanks so much! @Dan_Barak1

1 Like

Hey @Dan_Barak1. This snippet has been working great, but I now need it to display in a sentence structure with commas. I saw something in another forum post with the formula of {=join(option, "BLAZE_AND")} but this only displays the "Home 1", "Home 2", etc. What would I need to change so that it displays the actual snippet that I am importing? Appreciate your help. Thank you!

Justin can you explain a bit more what you are trying to do and what the {imports} are?

I'm not sure {imports} are the right choice for you here. There could be a simpler way to do what you are trying to do that would better support join()'ing things with commas.

Good morning,

The imports are snippets of different website selections of the inquired homes our clients wish to tour. Would it work best if I had just put the selector straight into the if commands? If someone has the time to chat, Iā€™d be more than happy to show the larger idea I am trying to implement.

Appreciate your time

Sure, happy to chat, email support@blaze.today and we can set up a video call.