# Working w/ComboBox and Arrays, having trouble passing a variable to DataProvider

**URL:** <https://forum.kirupa.com/t/working-w-combobox-and-arrays-having-trouble-passing-a-variable-to-dataprovider/248111>\
**Category:** Uncategorized\
**Created:** [January 3, 2008, 11:05pm UTC](https://forum.kirupa.com/t/working-w-combobox-and-arrays-having-trouble-passing-a-variable-to-dataprovider/248111 "2008-01-03T23:05:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![caraticus](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/caraticus/32/4195_2.png) [@caraticus](https://forum.kirupa.com/u/caraticus)\
**Post date:** [January 3, 2008, 11:05pm UTC](https://forum.kirupa.com/t/working-w-combobox-and-arrays-having-trouble-passing-a-variable-to-dataprovider/248111/1 "2008-01-03T23:05:21Z")

</div>

Hi,

I’m trying to use a multidimensional array to dynamically populate a combobox. I’m trying to pass a variable, (whichLesson), from the constructor function to the DataProvider value field that resides in another function (initMenu). if I type in the value I want like so:

```auto
  var dp:DataProvider = new DataProvider(menuItems.lesson1);

```

it works fine… but when I replace the ‘lesson1’ with the variable name I’m trying to reference I get an empty combobox… no error messages… just an empty box. I’ve traced the variable and the information is being passed into the function. It’s just not registering it in the DataProvider field. Here’s my code:

```auto
 
public function HPSE_Main():void {
            initMenu("lesson1");
            menuTitles();
            loadMain();
            menuStyle();
        }
        private function initMenu(whichLesson):void {
            var menuItems:Array = new Array();
            menuItems["lesson1"] = ["1. Lesson 1 Introduction"]; 
            menuItems["lesson2"] = ["1. Lesson 2 Introduction"];
            menuItems["lesson3"] = ["1. Lesson 3 Introduction"];
            menuItems["lesson4"] = ["1. Lesson 4 Introduction"];
            menuItems["lesson5"] = ["1. Lesson 5 Introduction"];
            menuItems["lesson6"] = ["1. Lesson 6 Introduction"];
            menuItems["lesson7"] = ["1. Lesson 7 Introduction"];

            var dp:DataProvider = new DataProvider(menuItems.whichLesson);
            mainInterface.pageMenu.dataProvider = dp;
            trace(whichLesson);
        }

```

Thanks in advance!
