Looked through many of the questions about this - and could not find a real answer. So here goes...
I have a form where I will be dynamically adding sections (in this case "attendee information") and so I wanted to use names like firstName[0]
, firstName[1]
, etc. I have already written the code to add the sections with a new numeric index for each.
However...
When I attempt to use JQuery (or just plain JS) to read the values of any of the form fields (dynamically created or not), I'm getting undefined. If I change the names to firstName1
, firstName2
, etc., it works. Only when I use the numeric array indexes.. nada.
I've tried...
$('#firstName[' + indexNum + ']')val();
$('input[name=firstName[' + indexNum + ']]').val();
.. and a couple other things. (And yes, the ID is the same as the name.)
Is there something I'm missing?