Input Radio name Attribute
Definition and Usage
name
Sets or returns the value of the name attribute of the radio button.
Tip:You can use the name attribute to define a group of radio buttons (radio buttons with the same name belong to the same group).
The HTML name attribute is used to identify form data after form data is submitted to the server, or to reference form data on the client using JavaScript.
Note:Only form elements with the name attribute will pass their values when submitting the form.
See also:
HTML Reference Manual:HTML <input> name Attribute
Instance
Example 1
Get the name of the radio button:
var x = document.getElementById("myRadio").name;
Example 2
Change the checkbox name:
document.getElementById("myRadio").name = "newRadioName";
Syntax
Return name attribute:
radioObject.name
Set name attribute:
radioObject.name = name
Attribute Value
Value | Description |
---|---|
name | Specifies the name of the radio button. |
Technical Details
Return value: | String value representing the name of the radio button. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |