Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Find item in drop down list and select it?

  • Find item in drop down list and select it?

    Posted by Mitch Mann on March 6, 2013 at 1:15 pm

    I’m trying to programmatically select a drop down item by text, not by index number.

    This works great:

    myDropDownList.selection = 1;

    But I can’t seem to select by text, like this:

    myDropDownList.selection.text = “This Text”;

    Furthermore, I can’t seem to use indexOf to find the text in the dropdown’s array. Like this:

    myItemNumber = myDropDownList.items.indexOf(“This Text”);
    myDropDownList.selection = myItemNumber;

    In fact, indexOf seems to just work on a variable, not on an array.

    I know I can loop through the whole array, testing each item to see if it matches, but I’m curious about doing it the correct way.

    Thanks for any help!
    Mitch

    Mitch Mann replied 13 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 6, 2013 at 6:41 pm

    I can’t think of a good way to do it except that you could load the selections into an associative array once, and from then on use that array to give you the appropriate selection number for the corresponding text. Here’s a simple example, but you would load the array with text and selection indexes from your dropdown list:

    selections = [];

    selections[“Paris”] = 0;
    selections[“Rome”] = 1;
    selections[“London”] = 2;
    selections[“Berlin”] = 3;

    myDropDownList.selection = (selections[“London”]);

    Dan

  • Mitch Mann

    March 6, 2013 at 6:52 pm

    Hey, that’s clever. Thanks Dan!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy