richrock Posted December 22, 2008 Share Posted December 22, 2008 Hi, I've set up a form to process an array of items, and I can get the form to return, save, etc. But I noticed a small problem - when submitting a checkbox, the array sets it to [0], and not it's position in the form list. Here's the source for the form: // Create the table full of sale data while ($row = mysql_fetch_assoc($rSaleList)) { echo "<tr>\n"; echo "<td>\n"; echo "<input type='text' name='id[]' size='7' value='".$row['id']."' READONLY />"; echo "</td>\n"; echo "<td>\n"; echo "<input type='text' name='sale_num[]' size='2' maxlength='1' value='".$row['salenum']."' />"; echo "</td>\n"; echo "<td width='140'>\n"; echo "<input type='text' name='day[]' value='".$row['day']."' size='1' maxlength='2' /> - <input type='text' name='month[]' value='".$row['month']."' size='1' maxlength='2' /> - <input type='text' name='year[]' value='".$row['year']."' size='3' maxlength='4' />"; echo "</td>\n"; echo "<td width='50'>\n"; if ($row['active'] == 1) { echo "<input type='checkbox' name='published[]' value='1' "; echo "checked='yes'"; echo " />"; } elseif ($row['active'] == 0) { echo "<input type='checkbox' name='published[]' value='0' "; echo "/>"; } echo "</td>\n"; echo "</tr>\n"; } And here's the POST output after submitting, with the third item (out of 6) checked: POST: Array ( [id] => Array ( [0] => 1012 [1] => 1000 [2] => 4 [3] => 3 [4] => 2 [5] => 1 ) [sale_num] => Array ( [0] => 2 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 ) [day] => Array ( [0] => 11 [1] => 11 [2] => 00 [3] => 00 [4] => 00 [5] => 00 ) [month] => Array ( [0] => 03 [1] => 03 [2] => 00 [3] => 00 [4] => 00 [5] => 00 ) [year] => Array ( [0] => 2009 [1] => 2009 [2] => 0000 [3] => 0000 [4] => 0000 [5] => 0000 ) [published] => Array ( [0] => 0 ) [updateSale] => Update Sales So how would I get [published] to show [4] => 0 ? (or 1, depending on it's selection)... TIA Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.