Dashboards & Visualizations

Fill default option from dropdown with a token

DanielSp
Explorer

Hello,

I have a dropdown that I need to be filled depending other dropdown
Dropdown1:
A->X
B->Y,Z
C->W,Z

If I selected A in the first one, I need that appear already selected X in the second dropdown
If I selected B in the second one, I need that appear already selected (change from previous selection) to Y,Z in the second dropdown
If I selected C in the thirstone, I need that appear already selected (change from previous selection) to W,Z in the second dropdown

I tried with a token in the first dropdown and put the follow code in the second dropdown
<default>$token$</default>
It would work with only ONE value, but I not achieve that work for B and C that have 2 values

Could you please help me with It?
Thanks a lot

Labels (1)
0 Karma
1 Solution

ITWhisperer
Ultra Champion

If I understand correctly, the second dropdown is a multi-select which you want some of the options preselected based on the choice of the first dropdown?

    <input type="dropdown" token="choice" searchWhenChanged="true">
      <label>Choice</label>
      <choice value="X">A</choice>
      <choice value="Y,Z">B</choice>
      <choice value="W,Z">C</choice>
      <change>
        <eval token="form.preselect">split($choice$,",")</eval>
      </change>
    </input>
    <input type="multiselect" token="preselect" searchWhenChanged="true">
      <label>Preselect</label>
      <choice value="W">W</choice>
      <choice value="X">X</choice>
      <choice value="Y">Y</choice>
      <choice value="Z">Z</choice>
    </input>

View solution in original post

DanielSp
Explorer

Thanks a lot¡ It works¡

0 Karma

ITWhisperer
Ultra Champion

If I understand correctly, the second dropdown is a multi-select which you want some of the options preselected based on the choice of the first dropdown?

    <input type="dropdown" token="choice" searchWhenChanged="true">
      <label>Choice</label>
      <choice value="X">A</choice>
      <choice value="Y,Z">B</choice>
      <choice value="W,Z">C</choice>
      <change>
        <eval token="form.preselect">split($choice$,",")</eval>
      </change>
    </input>
    <input type="multiselect" token="preselect" searchWhenChanged="true">
      <label>Preselect</label>
      <choice value="W">W</choice>
      <choice value="X">X</choice>
      <choice value="Y">Y</choice>
      <choice value="Z">Z</choice>
    </input>

View solution in original post