views:

323

answers:

2

In my application i used combobox and adding value using dataprovider like

   id="teamComboBox" dataProvider="{xml_teamcoupon.lastResult.coupon.teamcoupon_name}

my xml like this

<pick15>
<coupon>
<teamcoupon_id>1</teamcoupon_id>
<teamcoupon_name>teamcoupon1</teamcoupon_name>
coupon></pick15>

so comobobox shows team coupon name . But what i want, ifi choose team coupon name then Correspond teamcoupon id how can i get . i trid teamComboBox.selectedItem.teamcoupon_id but shows error

A: 

Since the id node is on the same level as the name node, you'll need to reference the parent node first.

Something like:

teamComboBox.selectedItem.parent().teamcoupon_id
Christophe Herreman
Thank you so much Christophe Herreman . i tired it's also working
R.Vijayakumar
+1  A: 

Bind to the coupon element, rather than the teamcoupon_name element, and then use the labelField attribute of the combobox to reference teamcoupon_name.

<mx:ComboBox dataProvider="{xml_teamcoupon.lastResult.coupon}" labelField="teamcoupon_name" />

Now, you can get the currently selected element using combobox.selectedItem, and the id by referencing combobox.selectedItem.teamcoupon_id.

Dan Monego
thank you Dan Monego so much It's working
R.Vijayakumar