This always works for me.. ========================================== /* -------------------------------------------------------- *\ ** chk[] is the list of check boxes sent to browser. ** If chk[$i] equals $i as as you loop ** through the array.. then it was checked. ** But first we need to set all the boxes that ** ain't checked to -1 or something other than $i ** $num_chk = number of $chk[] boxes sent \* -------------------------------------------------------- */ for ($i=$num_chk; $i>-1 ; $i--) { if (!isset($chk[$i])) $chk[$i] = -1; else { $ii = $chk[$i]; $chk[$i] = -1; $chk[$ii] = $ii; } } /* Now you can loop through the chk[] ** list and find out what ones were set */ ============================================================= HTH. Good luck ... Dan
Dirk Beijaard wrote: > Hey all, > > I have a form, generated in php, with a lot of checkboxes on it. They > are initialized from the db. All checkboxes are in a 2d array and they > come through to my processing script fine. The only problem is that > the ones that are unchecked do not come through. I know that the post > command only sends the checked boxes. What I would like to know is which > ones were changed, ie checked or unchecked by the user. Right now I do > it by putting a string with the old values in a hidden textbox and > comparing those to what I get back in the array. I have been thinking > about writing some client side script to produce the differences. > > Does anyone know if there is a better way to do this? > > Thanks, > Dirk. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php