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
.
aForm = aSelectElement.form.selectname;
<form action="http://www.google.com/search" method="get"> <label>Google: <input type="search" name="q"></label> <input type="submit" value="Search..."> </form>
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>
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'form' in that specification. | Living Standard | |
HTML5 The definition of 'HTMLSelectElement' in that specification. | Recommendation | Initial definition, snapshot of HTML Living Standard. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/form