Easy Tutorial
❮ Met Canvas Rect Coll Map Areas ❯

Radio form Attribute


Definition and Usage

The form attribute returns a reference to the form that contains the button.

If successful, this attribute returns a form object.

Syntax


Browser Support

All major browsers support the form attribute.


Example

The following example will return the ID of the form to which the radio button belongs:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function displayResult(){
    var x=document.getElementById("red").form.id;
    alert(x);
}
</script>
</head>
<body>

<form id="form1">
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()">Display Form ID</button>

</body>
</html>

❮ Met Canvas Rect Coll Map Areas ❯