Reading data in to ComboBox from PHP page. (corrections)

June 21, 2008

Actually I made this post long back but the post had some corrections so iam making those here. It was actually suggested by a a person called John that he didn’t get the post clearly and insisted to make another one for newbies. So I decided to make a clear one here with complete code.

The post missed one line as it was pointed out in the comment , the line is to send the HttpService you are using to get the Data.

Flex code :

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute

creationComplete=”projectsSrv.send();”>

<mx:HTTPService

id=”projectsSrv

url=”new.xml

useProxy=”false” method=”POST>

</mx:HTTPService>

<mx:ComboBox

id=”cmb1” x=”152” y=”53

dataProvider=”{projectsSrv.lastResult.records.record}

labelField=”data></mx:ComboBox>

</mx:Application>

PHP code or XML file code:

<records>

<record data=”1″ label=”Corco”/>

<record data=”5″ label=”Shell Crop Protection”/>

<record data=”7″ label=”Olin McIntosh”/>

<record data=”9″ label=”Crab Orchard”/>

<record data=”10″ label=”Shell Oil Del Amo”/>

<record data=”11″ label=”AIG South Jersey Gas”/>

<record data=”12″ label=”Husch &amp; Eppenberger Litigation-New York”/>

<record data=”22″ label=”Shell Sturbridge”/><record data=”24″ label=”Shell Southington”/>

<record data=”26″ label=”Olin Personal Injury”/>

</records>

You can send data in this format or get it from the XML file, here its from XML file “new.xml”.you can even echo these lines in PHP and a file as new.php.

As you can see the difference here, from that post is, here iam using the line creationComplete=”projectsSrv.send();” in the Application tag to send the service and read the data.

Now it will work fine and comments are welcome !