Flex - How to send the ID of the selected item of a Flex DropDownList to the server?
I am using FlashBuilder 4.5 for PHP. I have a simple MySQL table with the fields {tID, tName}.
I am able to populate a DropDownList in a Flex form as below. The DropDownList shows the name of the people without problem:
<s:Form defaultButton="{button}">
<s:FormItem label="myList: ">
<s:DropDownList id="dropDownList" creationComplete="dropDownList_crea开发者_如何学GotionCompleteHandler(event)" >
<s:AsyncListView list="{getPeopleResult.lastResult}"/>
</s:DropDownList>
</s:FormItem>
<s:Button id="button" label="Submit"click="button_clickHandler(event)"/>
</s:Form>
In my button_clickHandler function, I want to obtain the ID of the selected item from the dropdownlist:
protected function button_clickHandler(event:MouseEvent):void
{
person.tID=dropDownList.selectedItem as int;
createpersonResult.token=personservice.createperson(person);
}
The above does not work. I would appreciate any help!
You probably need this or similar :
person.tID=dropDownList.selectedItem.tID as int;
The straight value of dropDownList.selectedItem
is probably "[Object]" - Most likely a person
object with the fields tID
and tName
.
This is my guess based off the code I can see so far... :)
You should always use parseInt() OR parseFloat() for conversion from Number to String. That will solve your problem.
精彩评论