...

View Full Version : Passing an array to POST



rpjd
02-24-2011, 07:59 PM
I'm submitting a form with with table structure:


<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?

wldrumstcs
02-24-2011, 08:36 PM
You have to give the inputs names. Otherwise, you can't access them.

rpjd
02-24-2011, 08:57 PM
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?

bullant
02-24-2011, 10:42 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum