views:

396

answers:

1

Hi!

I'm trying to set a combobox's dataprovider. I have 2 comboboxes: cb_div and cb_stores. For cb_div, I get to set the data provider correctly with an XML file. Cb_stores' dataprovider is to be set depending on the selected item of cb_div.

First, here are my XML files. Data provider for cb_div:

<?xml version="1.0" encoding="UTF-8"?>
<divisions>
 <division id="Japan">Japan</division>
 <division id="Europe">Europe</division>
</divisions>

Data provider for cb_stores:

<list>
 <stores name="Europe">
  <store>BOUTIQUE HARROD'S</store>
  <store>GALERIES LAFAYETTE LILLE</store>
  <store>GALERIES LAFAYETTE SAISONNIERE</store>
 </stores>
 <stores name="Japan">
  <store>ODEIS PACK HANZOMON</store>
  <store>GINZA</store>
  <store>OMOTESANDO</store>
 </stores>
</list>

What I'm trying to do is the following: if the user selects "Japan" in cb_div, the dataprovider of cb_stores should be the stores under <stores name="Japan">, if he selects "Europe", the dataprovider should be <stores name="Europe">.

This is what I've done and it's not working: it returns every stores.

<mx:Script>
 <![CDATA[
  import mx.controls.Alert;
  private function division_change():void
  {
   Alert.show(division.selectedItem.toString());
   var temp:XMLList = stores.stores.(@name=division.selectedItem);
   store.dataProvider = temp.store;
  }
 ]]>
</mx:Script>
<mx:VBox verticalGap="10">
 <mx:ComboBox id="division" dataProvider="{divisions.division}" change="division_change()" prompt=" "/>
 <mx:ComboBox id="store" prompt=" "/>
 <mx:TextInput id="password" displayAsPassword="true"/> 
</mx:VBox>

Thanks for any help you can provide.

Regards

+1  A: 

right off the bat

 var temp:XMLList = stores.stores.(@name=division.selectedItem);

needs to be

var temp:XMLList = stores.stores.(@name==division.selectedItem);

notice the "=="

change that and see what else is going wrong.

invertedSpear
Great!!Wasn't careful enough >_<Thanks a lot =)
BS_C3
Always helps to have a fresh set of eyes review your code. Glad to have helped.
invertedSpear