Skip to main content
Corvinus Corax
Inspiring
September 6, 2021
Answered

Set Dropdown Menu values with expressions

  • September 6, 2021
  • 1 reply
  • 957 views

Is it possible to set a Dropdown Menu Item Value with an expression? I tried

 

effect("TestLayer")("Menu")(1).value = "Test"

effect("TestLayer")("Menu").item(1).value = "Test"

effect("TestLayer")("Menu").item(1).setValue("Test")

 

But nothing seems to work...

This topic has been closed for replies.
Correct answer Martin_Ritter

You cannot set the items of the dropdown with an expression.

 

*Martin

1 reply

Mylenium
Legend
September 6, 2021

The dropdown only returns an index or an UI string from the custom list. The actual magic has to happen inside your expression by e.g. associating the index with an array value or whatever. Expressions have no way to hard-set an external reference, so what you seem to have in mind won't work, anyway. You have to include all references in your expression and then pick the one you want to process via your code.

 

Mylenium

Corvinus Corax
Inspiring
September 6, 2021

Thanks Mylenium. I think I used the wrong syntax for my description. What I'm actually looking for is a way to fill the descriptive names of the items - I know, that the "values" are actually the indeces, thats fine.

 

So, as example, this is what I'm looking for:

 

Dropdown 1 lists "Theme 1", "Theme 2" and "Theme 3" (static elements)

Dropdown 2 should be dynamic. So, in pseudocode:

 

if(Dropdown 1 == "Theme 1")

{

Dropdown 2.item(1).text = "Theme 1 Item 1";

Dropdown 2.item(2)...

}

else if(Dropdown 1 == "Theme 2"){

Dropdown 2.item(1).text = "Theme 2 Item 1";

Dropdown 2.item(2)...

}

else if(Dropdown 1 == "Theme 3"){

Dropdown 2.item(1).text = "Theme 3 Item 1";

Dropdown 2.item(2)...

}

 

So what I'm actually looking for is a way to rename or create items of a given dropdown menu.

Martin_Ritter
Martin_RitterCorrect answer
Legend
September 6, 2021

You cannot set the items of the dropdown with an expression.

 

*Martin