The HTMLSelectElement.form
read-only property returns a HTMLFormElement
representing the form that this element is associated with. If the element is not associated with of a <form>
element, then it returns null
.
Syntax
aForm = aSelectElement.form.selectname;
Example
HTML
<form action="http://www.google.com/search" method="get"> <label>Google: <input type="search" name="q"></label> <input type="submit" value="Search..."> </form>
Javascript
A property available on all form elements, "type" returns the type of the calling form element. For SELECT, the two possible values are "select-one
" or "select-multiple
", depending on the type of selection list. The below code gives all SELECT elements in a particular form a CSS class of "selectclass
":
<script type="text/javascript"> var form_element = document.getElementById('subscribe_form'); var vist = form_element.style; if (vist.display=='' || vist.display=='none') { vist.display = 'block'; } else { vist.display = 'none'; } </script>
Specifications
Specification | Status | Comment |
HTML Living StandardThe definition of 'form' in that specification. | Living Standard | |
HTML5The definition of 'HTMLSelectElement' in that specification. | Recommendation | Initial definition, snapshot of HTML Living Standard. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
form
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support Yes |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
HTMLSelectElement.form by Mozilla Contributors is licensed under CC-BY-SA 2.5.