Select formProperty

Select 对象参考手册Select Object

Definition and Usage

The form property returns a reference to the form element containing the drop-down list.

This property returns the form object.

Syntax

selectObject.form


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the form property.


Example

Example

Show the id of the form containing the drop-down list:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</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()">Show the ID of the form it belongs to</button>
    
</body>
</html>

Try it yourself »


Select 对象参考手册Select Object Other Extensions