Copy link to clipboard
Copied
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...
You cannot set the items of the dropdown with an expression.
*Martin
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You cannot set the items of the dropdown with an expression.
*Martin
Copy link to clipboard
Copied
I was afraid so, but hoped for it 😉 Thanks for the confirmation though.