I've been having a lot of troubles with this for the past few hours right now and I'm really not seeing where the problem is. Every single code snippet I find on the Internet is telling me I'm doing it right, but for some reason, nothing is working.
Basically, I have a form that requires fields to be dynamically added depending on the number of fields needed. My javascript to do this works fine:
function ajouterStagiaires()
{
var innerHTML = new String();
innerHTML = document.getElementById('stagiaires').innerHTML;
var nombreStagiaires = document.getElementById('nbStagiairesConnus').value;
innerHTML += "<tr><td><b>Nom </b></td><td><b>Matricule</b> </td></tr>";
for(var i=0;i<nombreStagiaires;i++)
{
innerHTML += "<tr><td><input type='text' name='noms[]' /></td><td><input type='text' name='matricules[]' /></td></tr>";
}
document.getElementById('stagiaires').innerHTML = innerHTML;
document.getElementById('nbStagiairesConnus').value = nombreStagiaires;
}
The fields are added properly in the page, but when I go to my PHP code, the $_POSTs done on noms and matricules are not being "detected" (yes, I have things entered in my fields in the web page).
if (isset($_POST['matricules']))
{
echo "foo";
}
The "foo" is never printed. I have troubleshooted most of the common mistakes: my fields being added ARE in the form (CodeIgniter's echo form_open_multipart('foobar');). Every other field inside the form works perfectly fine.
The only thing I can see is that CodeIgniter is having problems with the JavaScript or something of the kind (though I don't know WHY it would have problems with it...) but other than that, I am completely stumped.
Thanks in advance.