<form> <div class="btn-group" name="gender" data-toggle="buttons"> <label class="btn btn-default"> <input type="radio" value="m">M </label> <label class="btn btn-default"> <input type="radio" value="f">Ж </label> </div> <button type="button" class="btn" id="save">Продолжить</button> </form> 

Why is the name="gender" attribute of such a form not being transmitted to the server? How to set an attribute to a group of buttons?

    2 answers 2

    It's impossible. Each HTML tag has its own set of attributes. In the case of the div tag, the name attribute is not provided by the standard. The div tag has a different purpose than form elements. In other words, the div tag is a grouping element and does not refer to a form element whose values ​​are transmitted to the server along with an HTTP request.

    The name attribute in relation to forms and their fields is used to enable the programmer in the server-side code to access the form field values ​​sent to the server in an HTTP request.

    The name attribute will be available on the server side only if you use it with form elements.

    A list of HTML form elements can be found here: http://www.w3schools.com/html/html_form_elements.asp

      Because the name attribute should be at input , not at div : https://webref.ru/html/input/name