Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    123
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Passing an array to POST

    I'm submitting a form with with table structure:
    Code:
    <table method="POST" action="file.php">
    <td><input type="checkbox" name="checkboxArray[]" value="xyz"></td>
    <td><input type="text" value="x"></td>
    <td><input type="text" value="y"></td>
    <td><input type="text" value="z"></td>
    <td name="textArray[]></td>
    There are several table involved.
    My problem is that when I try to access the arrays, only the checkboxArray is available/visible in $_POST. Does anyone have a solution?

  • #2
    Regular Coder
    Join Date
    Jul 2009
    Location
    Chicago, IL
    Posts
    169
    Thanks
    26
    Thanked 3 Times in 3 Posts
    You have to give the inputs names. Otherwise, you can't access them.

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    123
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry, the checkboxArray and textArray are the only values I need to access. Using array_key_exists() and empty() I can access checboxArray[], but having a problem with textArray. I think the problem is that I'm passing an array name and a value for each checkbox, I'm only passing an array name for the table cell text. How can I pass the text in the cell as an array element?

  • #4
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by rpjd View Post
    How can I pass the text in the cell as an array element?
    Options include

    1) put a readonly textbox in the cell and the cell text in the textbox. Then give the textboxes the same or different names.

    2) use javascript to copy the cell text to type="hidden" textboxes elsewhere in the form first before submitting the form. The hidden texboxes can have the same or different names.


  •  

    Posting Permissions

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