PHP: Getting Post Information
Hey, well the problem is that I have a form with a few fields. When you click the add row button it adds a row to the table with the same fields for the user to enter. My question is, how can I get all the information the user entered in a specific field throughout the table. Here is an example..
Name|Age
Jon | 17
Joe | 59
Kelly | 25
Now I want to get the names, but since the new created fields have the same name as the first field, I get just "Kelly" when I want to get all of them. Do you understand? Javascript is creating fields under the same name and I can only access one of them. I want to be able to create them under the same name, but have access to all of them.
Thanks
Re: PHP: Getting Post Information
Not possible. What you need to do is sort of your javascript.
I'm taking a blind guess at your code, but you'll need something like this
Code:
var tablebody = .........
var newrow = doument.createElement('tr');
var newtd = document.createElement('td');
var newinput = document.createElement('input');
newinput.type = 'text';
newinput.name = 'name_' + tablebody.rows.length;
newtd.appendChild(newinput);
newrow.appendChild(newtd);
newtd = document.createElement('td');
newinput = document.createElement('input');
newinput.type = 'text';
newinput.name = 'age_' + tablebody.rows.length;
newtd.appendChild(newinput);
newrow.appendChild(newtd);
tablebody.appendChild(newtr);
You could also have a hidden input which keeps track of how many rows there are.
Re: PHP: Getting Post Information
Short and simple...You need to be using arrays as the names of the <inputs>.
Re: PHP: Getting Post Information
What I ended up doing was sort of appending a number each time a new field was created. Then I can access each one by going through a for loop and looking at the values after appending numbers.
thanks