dependent drop down list

Posted on 2011-05-02
Last Modified: 2012-05-11
when a user selects a category from the first drop down box then i want the 2nd drop down to be updated based on the selection of the first drop down.  The code below works well but the only problem is that - all the categories are hard coded and i have hundreds of categories in which i cannot manually put all these categories in the code.  So is there a way to automate this without me hard coding all these categories?  thanks
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="" 
			import mx.collections.ArrayCollection;
			public var depts:ArrayCollection = new ArrayCollection([
				{label:"Electronics", data:1}, 
				{label:"Home Goods", data:2},
				{label:"Toys", data:3} ]);
			public var elecItems:ArrayCollection = new ArrayCollection([
				{label:"Samsung 25in TV", data:299}, 
				{label:"Panasonic Plasma", data:999}, 
				{label:"Sony LCD", data:899} ]);
			public var homeItems:ArrayCollection = new ArrayCollection([
				{label:"Blendtec Blender", data:399}, 
				{label:"Hoover Vaccuum", data:599}, 
				{label:"Black & Decker Toaster", data:99} ]);
			public var toyItems:ArrayCollection = new ArrayCollection([
				{label:"Nintendo DS", data:120}, 
				{label:"Lego's Star Wars Set", data:50}, 
				{label:"Leapfrog Leapster", data:30} ]);
			private function handleDepartmentSelected(event:IndexChangeEvent):void
				list2.prompt="Select Item";
				list2.selectedIndex=-1; // reset so prompt shows
				if (list1.selectedIndex==0)
				else if (list1.selectedIndex==1)
				else if (list1.selectedIndex==2)
	<!-- Note: A custom panel skin is used for the Tour de Flex samples and is included in the
	source tabs for each sample.    -->
	<s:Panel title="DropDownList Sample" 
			 width="100%" height="100%" 
		<s:VGroup width="100%" height="100%" left="120" top="5">
			<s:Label text="RJ's Warehouse Price Checker" fontSize="18" color="0x014f9f"/>
			<s:DropDownList id="list1" width="50%" dataProvider="{depts}" labelField="label" 
							prompt="Select Category"
			<s:Label id="text2"/>
			<s:DropDownList id="list2" width="50%" labelField="label" prompt="None"/>
			<mx:Spacer height="10"/>
			<s:Label fontSize="14" color="0x336699" text="The price of item: {list2.selectedItem.label} is: ${}" verticalAlign="bottom"/>

Open in new window

Question by:karinos57
    LVL 28

    Expert Comment

    by:Pravin Asar
    Use the flex remote object calls to fetch the data for second comboBox based on the option selected for first comboBox.


    Author Comment

    how you do that?
    LVL 28

    Accepted Solution

    The serverside mechanics of Remoteobject is dependent on your server language and datasource.

    To learn more about how RemoteObject, refer


    Author Closing Comment


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Text To Speech Reader For Adobe Flash Pages 4 816
    Flash being Disabled - help! 20 325
    Youtube video error 30 670
    Adobe Indesign CS6 4 56
    This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
    Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now