1 Reply Latest reply on Nov 10, 2009 6:43 AM by Kasyan Servetsky

    Dropdownlist question

    scriptworker Level 1

      Hello,

       

      A question about dropdowns.

      I have two dropdowns in a menu.

       

      The data in the second dropdown is dependant

      on the choise in the first dropdown.

       

      How can I dynamically change the data in the

      second dropdown when a choise is made in

      the first one?

       

      Kind regards,

      Michel

        • 1. Re: Dropdownlist question
          Kasyan Servetsky Level 5

          Use onChange() function.

           

          Here is an example:

           

          var dlg = new Window('dialog', 'Test');

          var myList = [ "One", "Two",  "Three", "Four", "Five" ];
          dlg.ddlist1 = dlg.add('dropdownlist', undefined, myList);
          dlg.ddlist1.selection = dlg.ddlist1.items[0];
          dlg.ddlist2 = dlg.add('dropdownlist', undefined, myList);
          dlg.ddlist2.selection = dlg.ddlist2.items[1];

          dlg.ddlist1.onChange = function() {
              dlg.ddlist2.selection = dlg.ddlist1.selection.index;
          }

          dlg.ddlist2.onChange = function() {
              dlg.ddlist1.selection = dlg.ddlist2.selection.index;
          }

          dlg.show();

           

           

          Changing selection in one dropdown list synchronizes the other dropdown list.

           

          Kasyan