[haXe] would Http class support multiple values for one parameter?
Laurent Bedubourg
lbedubourg at motion-twin.com
Thu Sep 14 11:04:14 CEST 2006
Wei Litao wrote:
> but if it support arrays. then it is easy to play with html checkbox.
>
> On 9/13/06, Benjamin Dasnois <benjamin.dasnois at gmail.com> wrote:
>> Isn't it possible to use the haXe Serializer in such a case?! It seems
>> to me that's it's the most straightforward way of passing complex
>> objects through an URL...
>>
>> On 9/13/06, Nicolas Cannasse <ncannasse at motion-twin.com> wrote:
>> > > Sorry for my poor english:)
>> > > it means i want a request like:
>> http://www.example.com/cook.n?food=foo&food=bar
>> > > so how to set the food parameter to ['foo', 'bar'] using
>> Http.setParameter?
>> >
>> > Parameters are strings, not arrays.
>> > You can for example do the following :
>> >
>> > url : htpp://www.example.com/cook.n?food=foo:bar
>> >
>> > Then later :
>> >
>> > var food = neko.Web.getParams().get("food").split(":");
>> >
>> > Nicolas
>> >
In CVS:
neko.Web.getParamValues(varName) : Array<String>
Handles array of values transmitted from HTML :
<form method="post" action="/foo">
<input type="checkbox" name="items[]" value="123"/> I want this item
<input type="checkbox" name="items[]" value="456"/> This one too
<input type="submit" value="go"/>
</form>
In haxe, if both items checked :
neko.Web.getParamValues("items") = ["123","456"];
You can also specify array indexes for your values :
Email1 : <input type="text" name="emails[0]"/>
Email3 : <input type="text" name="emails[2]"/>
...
neko.Web.getParamValues("emails") = ["foo at foo.com", null, "bar at bar.com"]
Regards
--
Laurent Bedubourg
lbedubourg at motion-twin.com
http://www.motion-twin.com
More information about the Haxe
mailing list