CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2006
    Posts
    62

    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

  2. #2
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    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.
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: PHP: Getting Post Information

    Short and simple...You need to be using arrays as the names of the <inputs>.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Apr 2006
    Posts
    62

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured