4 Replies Latest reply on May 2, 2006 9:41 PM by C-Rock

    list box dataProvider?

    C-Rock Level 2
      i'm using flash remoting to return an array of names from a data base. i would like the names to populate a list box. that works. but when i try to use the "selected" name it's always undefined, why?

      var namesList = ("bob", "tom", "jerry");
      listbox2.dataProvider = namesList;

      it poplulates fine but when i need to use this i get undefined

      trace(listbox2.selectedItem.data);
      or if i use label it's still undefined????

      thanks for your help...

        • 1. Re: list box dataProvider?
          Bishop[Neo]
          Try this:
          var namesList = [{data:1,label:"bob"},{data:2,label:"tom"},{data:3,label:"jerry"}];
          listbox2.dataProvider = namesList;

          listbox2.onChange = function(){trace(this.selectedItem.label);}
          • 2. Re: list box dataProvider?
            C-Rock Level 2
            i'm returning the list in the form i showed...

            var namesList = ("bob", "tom", "jerry");

            how do i make that end up in the format you have... i.e.

            {label:"bob", data:"bob"}, {label:"tom", data:"tom"}, {label:"jerry", data:"jerry"}

            i'm can only return the variables from coldfusion in the format under namesList.... how can i get to the desired format???


            Thanks
            • 3. Re: list box dataProvider?
              Bishop[Neo] Level 1
              trace(this.getItemAt(this.selectedIndex)); should work in that case.
              Of you could loop through the namesList array and populate the list with addItem();
              for(var x=0; x<namesList.length;x++){
              listbox2.addItem({label:x,data:namesList[x]});
              }
              • 4. Re: list box dataProvider?
                C-Rock Level 2
                i don't want to use the add item because when the user selects the name in the first list box another list box will populate with information. and using the additem will just keep adding items to the second list box. i want the first list box to use another function via flash remoting when it is selected. the results will be added to the second box. if the user were to another name in the list box then it would just add the information to the second list box list.