<sheldonlgwrote in message
news:uZ******************************@giganews.com ...
>I think this capability is lacking in php.
Suppose there is a group of checkboxes all named "procedure". Doing a
$_POST['procedure'] returns all the ones that are checked and not the ones
that are not checked. It would be nice if there were a way to get them
all and then discern which were checked. [Note: This can be done in
Javascript with document.getElementsByName('procedure') and then testing
whether each of the child nodes is checked].
This post arose from a question I had posted in comp.lang.mysql. I have a
group of checkboxes and I would like to be able to put them all into the
database table, specifying which was checked and which was not. The only
way I can see doing that is to (a) sort the array by ID that is returned
from the $_POST and (b) compare each element in it with a list of all the
checkboxes ordered by ID used to generate the form. A little tedious, but
it would work.
That goes to design or your script and implementation of the browser - which
is simply conforming to the w3c standard. You can define, whether from a
static array or from a db, what checkboxes are going to be shown. From
there, all you have to do is an array_intersect and array_diff to see what
boxes were and were not checked.
Other than making a mountain from a mole hill, this is a non-issue and
doesn't relate to php at all. If I've got an options page with dozens of
checkboxes, I don't want to consume bandwidth or processing time toting
superfluous information back and forth between client and server. A better
design on your end will help you appreciate the *good* implementation of the
w3c spec concerning checkboxes.
If you must mangle things, or if this will help you qwell your bitching, why
not use javascript on submit and simply create hidden inputs that coorespond
to each checkbox and whos values are either 1 or 0 depending on the checkbox
state at the time of submit. It would be nice if more people thought about
things before complaining to group of people who couldn't care less about
*off* topic, self-imposed shortcomings. THAT is what would be nice.