Latest web development tutorials

HTML DOM Radio name attribute

Radio Object Reference Radio Objects

Definition and Usage

name property sets or returns the name of the radio button.

Tip: Use thename attribute defines the radio button group (radio buttons with the same name in the same group).

name attribute is used after the form is submitted to the server to transmit data or form data referenced in Javascript.

Note: After the form is submitted only name attribute of the form element will pass data values.

grammar

Setting name attribute:

radioObject.name="name"

Returns the name attribute:

radioObject.name


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute name


Examples

Examples

Display name attribute value "Red" radio buttons:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function displayResult () {
var x = document.getElementById ( "red") name.;
alert (x);
}
</ Script>
</ Head>
<Body>

<Form>
Which color do you prefer? <br>
<Input type = "radio" name = "colors" id = "red"> red <br>
<Input type = "radio" name = "colors" id = "blue"> Blue <br>
<Input type = "radio" name = "colors" id = "green"> green
</ Form>
<Button type = "button" onclick = "displayResult ()"> red single box Button Name </ button>

</ Body>
</ Html>

try it"


Radio Object Reference Radio Objects