Easy Tutorial
❮ Jsref Min Prop Button Name ❯

form Attribute


Definition and Usage

The form attribute returns a reference to the form element that contains the dropdown list.

This attribute returns a form object.

Syntax


Browser Support

All major browsers support the form attribute.


Example

Display the form ID that contains the dropdown list:

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

<form id="form1">
Choose your favorite fruit:
<select id="mySelect">
    <option>Apple</option>
    <option>Orange</option>
    <option>Pineapple</option>
    <option>Banana</option>
</select>
</form>
<button type="button" onclick="displayResult()">Display Form ID</button>
    
</body>
</html>

❮ Jsref Min Prop Button Name ❯