0
Related to HTML FORM???
Having confusion with HTML form. what is the use of name and value attribute in the input tag.
3 Respuestas
+ 13
The name attribute in the input tag is used to reference elements in a Javascript. When aform is submitted, the values of the name attributes will also be passed to reference the form data.
The value attribute of the input tag is different for each element. If you have text field or password then the value means something that is initially written in the fields. If you have button then value means the text that is printed on the button. If you have radio buttons or checkboxes then the value means the text written in each options.
+ 12
Himanshu Rai
As both the radio buttons have same value in the name attribute, this means they are grouped together in one group and only one will be selected from the total available radio buttons. If you select one button and then select another then the first selected one will get unchecked.
And about <br /> tag , it is not important to add it always. If you want your input field to be below your label then you can add <br /> and if you want your field to be on the same line them no need to add the br element.
+ 2
Now having clear understanding of these attributes. Previously I thought that name attribute groups the input tags for same reason like in radio or checkbox when selecting gender.
Like This:
<Input type="radio" name="gender" value=male>Male<br/>
<Input type="radio" name="gender" value=female>Female<br/>
Here name groups the 2 input with catagory of gender for same reason, is this right???
Also, it is important to add <br/> tag after <input> tag???