PDA

View Full Version : Can I send POST/GET form fields as array?


kalex
05-16-2008, 06:05 PM
Hi everyone, thanks for any help on this.

I am new to flex and trying to convert a simple application from HTML. In an HTML form, you can send data as an array like so:


First Name: <input type="text" name="all[first_name]" size="30" />
Last Name: <input type="text" name="all[last_name]" size="30" />
Full Name: <input type="text" name="all[full_name]" size="30" />
Title: <input name="all[contact_title]" size="30" />

<!--And with a multiple selection box -->
<select size="45" multiple="multiple" name="cat[]">
<option value="01">One</option>
</select>


I am send the arrays to PHP via GET or POST and loop through them. So, my question is, is there anyway to duplicate this kind of thing with Flex? To send form data as an array? Thanks again for any responses.

Keith

kalex
05-16-2008, 07:38 PM
Ugh this is getting insanely annoying. How hard can this be? I mean what if you have something like

<mx:List x="36" y="40" width="323" height="702" id="search_cat" dataProvider="{contacts_flex.lastResult.combobox}" allowMultipleSelection="true" />

Soooo even if you have a multiple selection from a list you can't simply put it into an array? Beyond that, even if you get your form data into an array, I am starting to highly doubt that you can just throw that into something like

<mx:request>
<cat>{myArray}</cat>
</mx:request>

I know that I am missing a good amount of understanding here, but I am a programmer and this is frustrating as hell. Anyone have anything? Please?

kalex
05-16-2008, 07:50 PM
Ok, sorry, maybe I should show you what I'm working with.. I am not crazy about the AddChild crap but I am still new to this:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="contacts_flex.send()">
<mx:Script>
<![CDATA[
var portalURL:String="http://mysite.com/contacts_flex.php";

function createAll(fn, ln, fulln, ct, org) {
var all = new Array;
all[first_name]=fn;
all[last_name]=ln;
all[full_name]=fulln;
all[contact_title]=ct;
all[organization]=org;
contacts_flex.send; //add something to send here???
currentState=null;
return all;
}
]]>
</mx:Script>

<mx:HTTPService url="{portalURL}" id="contacts_flex" method="GET">
<mx:request>
<cat>{search_cat.selectedItem.data}</cat>
<!--<all></all> ??? no freaking clue-->
</mx:request>
</mx:HTTPService>

<mx:states>

<mx:State name="Advanced Search" basedOn="">
<mx:RemoveChild target="{mainPage}"/>
<mx:AddChild position="lastChild">
<mx:LinkButton x="36" y="10" label="Return to List" click="currentState=''"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:List x="36" y="40" width="323" height="702" id="search_cat" dataProvider="{contacts_flex.lastResult.combobox}" allowMultipleSelection="true" />
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:RadioButtonGroup id="search_type"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:RadioButton x="422" y="29" label="Exact Match" value="exact" groupName="search_type"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:RadioButton x="520" y="29" label="Fuzzy Match" value="fuzzy" groupName="search_type"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Label x="422" y="12" text="Search Type" fontWeight="bold"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Label x="422" y="59" text="First Name" fontWeight="bold"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Label x="422" y="102" text="Last Name" fontWeight="bold"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Label x="422" y="148" text="Full Name" fontWeight="bold"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Label x="422" y="191" text="Title" fontWeight="bold"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Label x="422" y="235" text="Organization" fontWeight="bold"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:TextInput x="422" y="74" width="300" id="first_name"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:TextInput x="422" y="118" width="300" id="last_name"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:TextInput x="422" y="163" width="300" id="full_name"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:TextInput x="422" y="207" width="300" id="contact_title"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:TextInput x="422" y="251" width="300" id="organization"/>
</mx:AddChild>
<mx:AddChild position="lastChild">
<mx:Button click="contacts_flex.send(currentState=null);" x="599" y="300" label="Search Database" id="search_db"/>
</mx:AddChild>

</mx:State>

</mx:states>

<mx:Panel id="mainPage" title="" horizontalScrollPolicy="off" verticalScrollPolicy="off" backgroundAlpha="0.0" x="0" y="0" layout="absolute">
<mx:Label x="10" y="30" text="Select a Primary Category:" fontWeight="normal" id="label_select_cat"/>
<mx:ComboBox x="10" y="50" id="cat" dataProvider="{contacts_flex.lastResult.combobox}">
<!--ComboBox param selectedIndex="{cat.selectedItem.data+1}" -->
</mx:ComboBox>
<mx:Button label="Go" click="contacts_flex.send();" id="button_select_cat" x="332" y="50"/>
<mx:LinkButton x="0" y="80" label="+ Add Contact" id="link_add_contact" enabled="true"/>
<mx:LinkButton x="110" y="80" label="Advanced Search" id="link_advanced_search" click="currentState='Advanced Search'" />
<mx:LinkButton x="237" y="80" label="Export Current List to Excel" id="link_excel_export"/>
<mx:DataGrid x="0" y="164" id="contacts" width="1255" height="575" dataProvider="{contacts_flex.lastResult.people.person}">
<mx:columns>
<mx:DataGridColumn headerText="Last Name" dataField="last_name"/>
<mx:DataGridColumn headerText="First Name" dataField="first_name"/>
<mx:DataGridColumn headerText="Organization" dataField="organization"/>
<mx:DataGridColumn headerText="Address" dataField="address_1"/>
<mx:DataGridColumn headerText="Address 2" dataField="address_2"/>
<mx:DataGridColumn headerText="City" dataField="city"/>
<mx:DataGridColumn headerText="State" dataField="state"/>
<mx:DataGridColumn headerText="Zip" dataField="zip"/>
</mx:columns>
</mx:DataGrid>

</mx:Panel>
</mx:Application>

kalex
05-16-2008, 08:43 PM
Is this forum more for designers than programmers? Does anyone know where else I can try?