开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜