<!DOCTYPE html>
<html>
<body>
<form id="myForm">
Select your favorite fruit:
<select id="mySelect">
<option>Apple</option>
<option>Orange</option>
<option >Pineapple</option>
<option>Banana</option>
</select>
</form>
<p>Click the button to return the id of the form the dropdown list belongs to.</p>
<button type="button" onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("mySelect").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>