I'm trying to pass through POST an array of checkboxes but this time it's not working (i've done the same things other times and everything was ok)
In a foreach loop i have this code to create the checkboxes:
$out .= "<td><input type='checkbox' value='$ordiniRiga->idRiga' name=\"etichetteArray[]\" id='mioId' ></td>";
But if i var_dump the $_POST (after checking all the checkboxes) i find that the array is NULL!(all the values ar numbers)
array(10) {
["idRiga1"]=>
string(2) "30"
["idRiga2"]=>
string(2) "31"
["etichetteArray"]=>
NULL
["idRiga3"]=>
string(2) "32"
["idRiga4"开发者_StackOverflow社区]=>
string(2) "33"
["idRiga5"]=>
string(2) "34"
["numRighe"]=>
string(1) "5"
["idOfferta"]=>
string(2) "32"
["idOrdine"]=>
string(2) "12"
["submitEtichette"]=>
string(16) "Stampa etichette"
}
Any idea of why this is happening?I'm using PHP 5.3 and Zend Server.
EDIT - The form it's really complex, i've created this fiddle http://jsfiddle.net/tVwLS/1/ so that you can see it.
EDIT - i0ve tried out the code on a LAMP and it works ok. Does anyone know if there is some kind of configuration that allows posting arrays?
Try removing the [] characters at the end of the name attribute, this may cause the problem.
I think the problem here is that checkboxes do not send their values to the server unless they are CHECKED.
There are a couple of other things wrong with this code (though they are probably not the root cause of your problem) -
- You should not assign the same ID to multiple checkboxes.
- Ideally the attributes of an HTML tag should be enclosed in double quotes (").
- The way you are writing the value attribute, it will not be the value you expect. You probably meant to write
value='".$ordiniRiga->idRiga."'
.
The problem was only with my home installation of zend_server.
精彩评论