Input attributes that can have the same “name”

前端 未结 7 696
野的像风
野的像风 2020-12-10 14:12

I noticed that if you have a couple of radios together, you are required to make the name attribute identical on all of them in order for the radios to work as expected:

相关标签:
7条回答
  • 2020-12-10 15:03

    It is perfectly valid to have the same value for name attributes on pages.

    A common fallback for checkboxes is to have a hidden input of the same name with a value set to false. When using the same name values tho be sure to double check the expected output, normally the latest value to be parsed will overwrite any previous parameters of the same name.

    If you need to group various fields under the same name you can actually create an array with multiple elements, eg:

    <input name="list[]" />
    <input name="list[]" />
    <input name="list[]" />
    
    0 讨论(0)
提交回复
热议问题