Page 1 of 1

Catching All Checkbox Changes

Posted: Wed Nov 15, 2006 10:29 am
by montecristo
Hi Guys

Just wondering if you could help me solve this problem. I create a table with values from my database.
The table is dynamically created and each row contains a checkbox

Code: Select all

<td align="center"><input type="checkbox" name=<?echo $i ; ?> value="webyn"></td>
The checkbox is checked or unchecked depending on a value in the database. If you check an unchecked box and press the submit button I can get the checked checkboxes using :

Code: Select all

foreach ($_POST as $key => $value )
	{
                  echo $key;
                }
Which works fine. Now my question! If the checkbox was originally checked and the user unchecks it and then presses the submit button. How can I tell that this button was unchecked?

Thanks in advance for your time

Posted: Wed Nov 15, 2006 10:32 am
by JayBird
You cant tell the checkbox was unchecked directly after the form submission. What you will have to do is compare the new checked values with the previous checked values in the database. Doing this, you should be able to determine which values were unchecked.

Posted: Wed Nov 15, 2006 10:38 am
by montecristo
Thanks, that makes a lot of sense!

Thank you for your time