2 Replies Latest reply on Apr 25, 2007 12:14 PM by InfoSciCo

    Dynamically adding item to List box


      I have a List box that is bound to an Array, and now I need to add some values to the List box.

      I can add a new item to the List box by hard-coding a value, such as:

      arrayData.addItem({'label':'test2', 'data':'99'});

      This works just fine. But the problem is that I don't know what the values will be,
      so I need a way ot dynamically adding a value via variables.

      I tried:

      var strLabel:String = "Some Text";
      var strData:String = "99";
      var newItem:Object = "{'label':'" + strLabel + "', 'data':'" + strData + "'}";

      And then adding it to the Array:


      But what shows up in the List box is:

      {'label':'Some Label', 'data':'99'}

      I tried every variation I could think of. What's the correct syntax to do this?