4/11/2010 7:56:05 PM
Title:
ComboBox
Basically, I have three comboboxes with different drop-down menus. When one item is selected on “myCombobox2”, I want another item on ”myCombobox3”. Below is some of my current code for the project.
myCombobox2.dropdown.setRendererStyle("textFormat" , myTextFormat);
myCombobox2.textField.setStyle("textFormat", myTextFormat);
myCombobox2.dropdown.rowHeight = 30;
myCombobox2.prompt = "Select";
myCombobox2.addItem({label:"Green", text:"green"})
myCombobox2.addItem({label:"Blue", text:"blue"})
myCombobox2.addItem({label:"Purple", text:"purple"})
myCombobox2.addItem({label:"Red", text:"red"})
myCombobox3.dropdown.setRendererStyle("textFormat" , myTextFormat);
myCombobox3.textField.setStyle("textFormat", myTextFormat);
myCombobox3.dropdown.rowHeight = 30;
myCombobox3.prompt = "Select";
myCombobox3.addItem({label:"Sweatshirt", text:"sweatshirt"})
myCombobox3.addItem({label:"T-shirt", text:"t-shirt"})
myCombobox3.addItem({label:"Pants", text:"pants"})
myCombobox3.addItem({label:"Shoes", text:"shoes"})
myCombobox3.addItem({label:"Sweater", text:"Sweater"})
How do I create code that says when “Green” has been selected, delete the “Sweater” option from “myCombobox3.” I also need “Sweater” to disappear when “Purple” has been selected.
Any help would be greatly appreciated.
Thanks!
Inder
Points: 2980
Posts:0
4/11/2010 9:49:57 PM
for such category filters , the values are predefined in a function or come from database when selected. For e.g see code below. Below code i have just written in notepad so code syntax is not checked. Wanted to give u an idea. When color combo is changed inside change listener function first remove all the items of myCombobox3 and then add the option depending upon whats selected from color combo using switch case statement
function comboChangeListener(evt:Event):void{
myCombobox3.removeAll();
switch slectedItem;
case "green"
myCombobox3.addItem({label:"Sweatshirt", text:"sweatshirt"})
myCombobox3.addItem({label:"T-shirt", text:"t-shirt"})
myCombobox3.addItem({label:"Pants", text:"pants"})
myCombobox3.addItem({label:"Shoes", text:"shoes"})
break;
case "purple"
myCombobox3.addItem({label:"Sweatshirt", text:"sweatshirt"})
myCombobox3.addItem({label:"T-shirt", text:"t-shirt"})
myCombobox3.addItem({label:"Pants", text:"pants"})
myCombobox3.addItem({label:"Shoes", text:"shoes"})
break;
case "Blue"
myCombobox3.addItem({label:"Pants", text:"pants"})
myCombobox3.addItem({label:"Shoes", text:"shoes"})
break;
}