<html>
<body>
<form id="myForm">
<label id="myLabel" for="male">Male</label>
<input type="radio" name="sex" id="male" value="male"><br>
</form>
<p>Click the "Try it" button to return the id of the form the label belongs to.</p>
<p id="demo"></p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var x = document.getElementById("myLabel").form.id;
document.getElementById("demo").innerHTML=x;
}
</script>
</body>
</html>