Several Checkboxes sharing the same name

前端 未结 2 957
猫巷女王i
猫巷女王i 2021-02-19 07:14

According to the w3c \"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.\"

2条回答
  •  無奈伤痛
    2021-02-19 08:08

    That would never have worked without the [], not in PHP.

    W3C don't specify anything about how query strings are handled server-side. (Ignoring an irrelevant, obsolete corner of the CGI spec, only relevant to PHP in that it was a security hole up until recently).

    It looks like that pattern is valid markup, but not commonly used, for the reason you describe.

    A similar pattern is used for radio buttons, of which only one can be selected at a time. (In fact, giving the radio inputs the same name is how the browser knows to treat them as a group). Perhaps that's what you were thinking of.

提交回复
热议问题