1

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_creationCompleteHandler(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!

Shailen
  • 7,909
  • 3
  • 29
  • 37

2 Answers2

0

You should always use parseInt() OR parseFloat() for conversion from Number to String. That will solve your problem.

M.D.
  • 1,886
  • 1
  • 13
  • 14
  • Sweet! Now, that works. I am now able to send the right data to the server when I add a new person. Now, the problem is that the datagrid is not properly updated. – Shailen Jul 19 '11 at 09:08
  • Since the question is different, I created a new question: http://stackoverflow.com/questions/6744972/flex-datagrid-not-updated-properly – Shailen Jul 19 '11 at 10:19
  • Datagrid now updates without problem! Your help is very much appreciated! – Shailen Jul 20 '11 at 22:40
0

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... :)

Nate
  • 2,881
  • 1
  • 14
  • 14