[thelist] Phorm and Checkboxes

.jeff jeff at members.evolt.org
Mon Jan 6 15:45:01 CST 2003


sasha,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: sasha
>
> Because they all have the same name?  $question_01 =
> 'item 1' is being overwritten by $question_01 =
> 'item 2'.  They should only have the same name if
> they're radios, not checkboxes.  The basics of forms.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

that's not true at all.  if they all have the same name and item 1 and item
2 are checked then, if php/phorm is doing things properly, $question_01
should be 'item 1,item 2'.  the browser simple collects all the successful
controls, combines same named ones (regardless of the type of control --
select-one, select-multiple, checkbox, text, password, hidden, and textarea)
into a comma-delimited list of values and sends them to the server.  some
are less useful to use in this fashion -- text, password, and textarea -- as
the user could potentially enter a comma in the field making it impossible
distinguish between user-entered commas and commas used to delimit values
for same-named elements.  interestingly, you can even have same-named, but
different typed controls that, if both successful, will create a
comma-delimited list of values.

from the w3.org:

  "Several checkboxes in a form may share the same
   control name. Thus, for example, checkboxes allow
   users to select several values for the same
   property. The INPUT element is used to create a
   checkbox control."

http://www.w3.org/TR/REC-html40/interact/forms.html#checkbox

the same is definitely true for a multi-select with more than one option
selected.

the only same-named elements that can't have more than one element
successful are radio buttons because they represent a set with a mutually
exclusive choice and buttons because only one control can be clicked by the
user at a time.

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list