6 Replies Latest reply on Apr 9, 2012 8:32 AM by Gonterman1201

    onChange change dropdownlist?

    Gonterman1201 Level 1

      I am using a dropdown list to make a selection and then based on that selection I would like the second dropdown list to change based on the election.

       

      myStandardDown.onChange = function () {if (myStandardDown.selection==1){myTypeDown = ("dropdownlist", undefined, lithoNames);}}

      I tried something like this and,

      this:

       

      if (myStandardDown.selection==0){myTypeDown =myInputGroup.add ("dropdownlist", undefined, execNames);}

       

       

      or

       

       

      myStandardDown.onChange = function () {if (myStandardDown.selection==1){myTypeDown.graphics = ("dropdownlist", undefined, lithoNames);}}

       

       

      I don't know. The end result I am going to have many things change based on this so this is the crux of it.

       

      I can get a text edit box to change but that is it.

       

      I have three different drop downs that it needs to change into.

       

      If you can lead me in the right direction it would be appreciated.

        • 1. Re: onChange change dropdownlist?
          Gonterman1201 Level 1

          I have tried this to

           

          myStandardDown.onChange = function () {if (myStandardDown.selection==1){myTypeDown =myInputGroup.add ("dropdownlist", undefined, lithoNames); myTypeDown.selection = myTypeDown.items[0];}}

           

          it did not change.

          • 2. Re: onChange change dropdownlist?
            Gonterman1201 Level 1

            You can specify the choice items on creation of the list object, or afterward using the list object’s add() method.

            Taken from javaScript Tools Guide.

             

            ListItem

            Items added to or inserted into any type of list control are ListItem objects, with properties that can be manipulated from a script. ListItem elements can be of the following types: uitem: the typical item in any type of list. It displays text or an image, and can be selected. To display an image, set the item object’s image property;

             

            also taken from javaScript Tools Guide.

             

            I still do not get it.

            • 3. Re: onChange change dropdownlist?
              Gonterman1201 Level 1

              if a dropdown list can not be changed using onChange let me know I will try and go in a different direction.

              • 4. Re: onChange change dropdownlist?
                Gonterman1201 Level 1

                Ok I feel like I am getting somewhere but I still need help.

                using and example for lists shown in scriptui-1-9 I can add to my drop down menu an item. However I want to replace those items depending on other selections. So I need to remove multiple items and replace them with multiple items.

                 

                myStandardDown.onChange = function () {if (myStandardDown.selection==1){myTypeDown.add ("item", lithoNames)}}

                this will add but it only adds one line I need it to be a menu with multiple lines. I also need to remove all the other Items in the dropdown.

                I hope this is clear.

                • 5. Re: onChange change dropdownlist?
                  Gonterman1201 Level 1

                  So now I am able to respond to an event a selection in a dropdown and now I am deleting the list and adding a new set of values into the list but when I add it adds the whole list not in a drop down.

                   

                  myStandardDown.onChange = function () {if (myStandardDown.selection==1){while (myTypeDown.items.length> 0) {myTypeDown.remove (myTypeDown.items[0]);}myTypeDown.add ("item", lithoNames);}}

                   

                  If I can figure this then I will have it.

                  • 6. Re: onChange change dropdownlist?
                    Gonterman1201 Level 1

                    So I think I have figured it out although if you have a better way of righting this feel free to post but this works.

                     

                    myStandardDown.onChange = function () {if (myStandardDown.selection==1){while (myTypeDown.items.length> 0) {myTypeDown.remove (myTypeDown.items[0]);}

                                for (var i = 0; i <lithoNames.length; i++){myTypeDown.add ("item", (lithoNames[i]));}myTypeDown.selection=0}

                            else if (myStandardDown.selection==2){while (myTypeDown.items.length> 0) {myTypeDown.remove (myTypeDown.items[0]);}

                                for (var i = 0; i <embossNames.length; i++){myTypeDown.add ("item", (embossNames[i]));}myTypeDown.selection=0}

                            else{while (myTypeDown.items.length> 0) {myTypeDown.remove (myTypeDown.items[0]);}

                                for (var i = 0; i <execNames.length; i++){myTypeDown.add ("item", (execNames[i]));}myTypeDown.selection=0}}

                     

                    basically on change it deletes the list from the drop down in a while loop then adds a list back in with a for loop depending on the selection that was made on change.