oulan / iui

Automatically exported from code.google.com/p/iui
MIT License
0 stars 0 forks source link

form with multiple checkboxes with same name don t work #239

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.I just create a simple form with checkbox with the same name
<input type="checkbox" value="1" name="id[]"/>
<input type="checkbox" value="2" name="id[]"/>
<input type="checkbox" value="3" name="id[]"/>
2. I select 2 or more of them and submit (GET OR POST)

What is the expected output? What do you see instead?
I hoped to receive many id[] values
I only received the LAST checked value.

What version of the product are you using? On what operating system?
Version 0.40-dev2

Please provide any additional information below.

Original issue reported on code.google.com by bignon.s...@gmail.com on 21 Apr 2010 at 1:57

GoogleCodeExporter commented 9 years ago
How I fixed it :

1) In submitForm method , i check if I already found the key. I create an array 
if I
have more than 1 value for this key, the push the values.
if (!args[inputs[i].name])
 args[inputs[i].name] = inputs[i].value;
else
{
if (args[inputs[i].name].constructor.toString().indexOf("Array") == -1)
{
  var tmp = args[inputs[i].name];
  args[inputs[i].name] = [];
  args[inputs[i].name].push(tmp);
}
 args[inputs[i].name].push(inputs[i].value);
}

2) When I serialize the params in the  param method, I check if my param is an 
array.
I the param is an array, I also corrcly serialize it.

if (o[key].constructor.toString().indexOf("Array") != -1)
{
 var tab = o[key];
//s[ s.length ] = iui.param(o[key]);
 for (var idx in tab)
 s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(tab[idx]);
 }
else
 s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(o[key]);

Original comment by bignon.s...@gmail.com on 21 Apr 2010 at 2:03

GoogleCodeExporter commented 9 years ago
This is a duplicate of #48, which is fixed in Git and will be fixed in the next 
release 0.40-beta3

Original comment by msgilli...@gmail.com on 3 Apr 2012 at 9:59