<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("red").name;
alert(x);
}
</script>
</head>
<body>
<form>
What 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()">Display name of "Red" radio button</button>
</body>
</html>