Posted by Geoff Berrow on 03/29/07 14:43
Message-ID: <1175177552.525042.244720@b75g2000hsg.googlegroups.com> from
mountain.dog@gmail.com contained the following:
>The problem is when the user un-checks a checkbox, the value does not
>get passed and the DB does not update - set/change it to 0. The only
>values that get passed are the checkboxes that are checked. Below is
>the query / code after the submit button has been pressed. Are radio
>buttons the answer? Any help / suggestions would be very much
>appreciated.
Checkboxes only return a value if checked. The solution is to make your
update query update all fields with the default value set to unchecked.
The unchecked fields will automatically be unchecked because the POSTed
value will not exist.
Of course you will have to explicitly name your check boxes something
like <input name='menu_show_attribute[".$row['menu_id']."]'
type='checkbox'
class='checkbox')
And of course you won't be able to loop through the array
$_POST['menu_show_attribute'] because the unchecked values will not
show. However you could include a hidden field
<input name='hidden_menu_id[".$row['menu_id']."]' type='hidden'>
Then update your db by looping through $_POST['hidden_menu_id']
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
[Back to original message]
|