public class JsSelectElement extends JsElement implements SelectElement
ALLOW_KEYBOARD_INPUT
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
SVG_ZOOMANDPAN_DISABLE, SVG_ZOOMANDPAN_MAGNIFY, SVG_ZOOMANDPAN_UNKNOWN
Modifier | Constructor and Description |
---|---|
protected |
JsSelectElement() |
Modifier and Type | Method and Description |
---|---|
void |
add(Element element,
Element before)
Adds an element to the collection of
option elements for this select element. |
boolean |
checkValidity()
|
JsFormElement |
getForm()
The form that this element is associated with.
|
JsNodeList |
getLabels()
A list of label elements associated with this select element.
|
int |
getLength()
The number of
<option>
elements in this select element. |
String |
getName()
Reflects the
name
HTML attribute, containing the name of this control used by servers and DOM search functions. |
JsHTMLOptionsCollection |
getOptions()
The set of
<option>
elements contained by this element. |
int |
getSelectedIndex()
The index of the first selected
<option>
element. |
JsHTMLCollection |
getSelectedOptions()
The set of options that are selected.
|
int |
getSize()
Reflects the
size
HTML attribute, which contains the number of visible items in the control. |
String |
getType()
The form control's type.
|
String |
getValidationMessage()
A localized message that describes the validation constraints that the control does not satisfy (if any).
|
JsValidityState |
getValidity()
The validity states that this control is in.
|
String |
getValue()
The value of this form control, that is, of the first selected option.
|
boolean |
isAutofocus()
Reflects the
autofocus
HTML attribute, which indicates whether the control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. |
boolean |
isDisabled()
Reflects the
disabled
HTML attribute, which indicates whether the control is disabled. |
boolean |
isMultiple()
Reflects the
multiple
HTML attribute, whichindicates whether multiple items can be selected. |
boolean |
isRequired()
Reflects the
required
HTML attribute, which indicates whether the user is required to select a value before submitting the form. |
boolean |
isWillValidate()
Indicates whether the button is a candidate for constraint validation.
|
JsNode |
item(int index)
|
JsNode |
namedItem(String name)
|
void |
remove(int index)
Removes the element at the specified index from the options collection for this select element.
|
void |
remove(OptionElement option)
Removes the element at the specified index from the options collection for this select element.
|
void |
setAutofocus(boolean param_autofocus) |
void |
setCustomValidity(String error)
HTML5 only.
|
void |
setDisabled(boolean param_disabled) |
void |
setLength(int param_length) |
void |
setMultiple(boolean param_multiple) |
void |
setName(String param_name) |
void |
setRequired(boolean param_required) |
void |
setSelectedIndex(int param_selectedIndex) |
void |
setSize(int param_size) |
void |
setValue(String param_value) |
blur, click, focus, getAccessKey, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getBoundingClientRect, getChildren, getClassList, getClassName, getClientHeight, getClientLeft, getClientRects, getClientTop, getClientWidth, getContentEditable, getDataset, getDir, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, getId, getInnerHTML, getInnerText, getLang, getOffsetHeight, getOffsetLeft, getOffsetParent, getOffsetTop, getOffsetWidth, getOnabort, getOnbeforecopy, getOnbeforecut, getOnbeforepaste, getOnblur, getOnchange, getOnclick, getOncontextmenu, getOncopy, getOncut, getOndblclick, getOndrag, getOndragend, getOndragenter, getOndragleave, getOndragover, getOndragstart, getOndrop, getOnerror, getOnfocus, getOninput, getOninvalid, getOnkeydown, getOnkeypress, getOnkeyup, getOnload, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnmousewheel, getOnpaste, getOnreset, getOnscroll, getOnsearch, getOnselect, getOnselectstart, getOnsubmit, getOntouchcancel, getOntouchend, getOntouchmove, getOntouchstart, getOnwebkitfullscreenchange, getOnwebkitfullscreenerror, getOuterHTML, getOuterText, getScrollHeight, getScrollLeft, getScrollTop, getScrollWidth, getStyle, getTabIndex, getTagName, getTitle, getWebkitdropzone, getWebkitRegionOverflow, hasAttribute, hasAttributeNS, insertAdjacentElement, insertAdjacentHTML, insertAdjacentText, isContentEditable, isDraggable, isHidden, isSpellcheck, isTranslate, removeAttribute, removeAttributeNode, removeAttributeNS, scrollByLines, scrollByPages, scrollIntoView, scrollIntoView, scrollIntoViewIfNeeded, scrollIntoViewIfNeeded, setAccessKey, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setClassName, setContentEditable, setDir, setDraggable, setHidden, setId, setInnerHTML, setInnerText, setLang, setOnabort, setOnbeforecopy, setOnbeforecut, setOnbeforepaste, setOnblur, setOnchange, setOnclick, setOncontextmenu, setOncopy, setOncut, setOndblclick, setOndrag, setOndragend, setOndragenter, setOndragleave, setOndragover, setOndragstart, setOndrop, setOnerror, setOnfocus, setOninput, setOninvalid, setOnkeydown, setOnkeypress, setOnkeyup, setOnload, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnmousewheel, setOnpaste, setOnreset, setOnscroll, setOnsearch, setOnselect, setOnselectstart, setOnsubmit, setOntouchcancel, setOntouchend, setOntouchmove, setOntouchstart, setOnwebkitfullscreenchange, setOnwebkitfullscreenerror, setOuterHTML, setOuterText, setScrollLeft, setScrollTop, setSpellcheck, setTabIndex, setTitle, setTranslate, setWebkitdropzone, webkitMatchesSelector, webkitRequestFullscreen, webkitRequestFullScreen
appendChild, cloneNode, compareDocumentPosition, contains, getAttributes, getBaseURI, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent
addEventListener, addEventListener, beginElement, beginElementAt, dispatchEvent, endElement, endElementAt, getAnimatedClassName, getAnimatedHeight, getAnimatedHref, getAnimatedResult, getAnimatedTransform, getAnimatedWidth, getAnimatedX, getAnimatedY, getBBox, getChildElementCount, getCTM, getExternalResourcesRequired, getFarthestViewportElement, getFirstElementChild, getLastElementChild, getNearestViewportElement, getNextElementSibling, getPresentationAttribute, getPreserveAspectRatio, getPreviousElementSibling, getRequiredExtensions, getRequiredFeatures, getScreenCTM, getSvgStyle, getSystemLanguage, getTransformToElement, getViewBox, getXmllang, getXmlspace, getZoomAndPan, hasExtension, querySelector, querySelectorAll, removeEventListener, removeEventListener, setXmllang, setXmlspace, setZoomAndPan
at, at, intAt, intAt, length, numberAt, numberAt, setAt, setAt, setAt, setAt, setAt, setAt
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
blur, click, focus, getAccessKey, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getBoundingClientRect, getChildElementCount, getChildren, getClassList, getClassName, getClientHeight, getClientLeft, getClientRects, getClientTop, getClientWidth, getContentEditable, getDataset, getDir, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, getFirstElementChild, getId, getInnerHTML, getInnerText, getLang, getLastElementChild, getNextElementSibling, getOffsetHeight, getOffsetLeft, getOffsetParent, getOffsetTop, getOffsetWidth, getOnabort, getOnbeforecopy, getOnbeforecut, getOnbeforepaste, getOnblur, getOnchange, getOnclick, getOncontextmenu, getOncopy, getOncut, getOndblclick, getOndrag, getOndragend, getOndragenter, getOndragleave, getOndragover, getOndragstart, getOndrop, getOnerror, getOnfocus, getOninput, getOninvalid, getOnkeydown, getOnkeypress, getOnkeyup, getOnload, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnmousewheel, getOnpaste, getOnreset, getOnscroll, getOnsearch, getOnselect, getOnselectstart, getOnsubmit, getOntouchcancel, getOntouchend, getOntouchmove, getOntouchstart, getOnwebkitfullscreenchange, getOnwebkitfullscreenerror, getOuterHTML, getOuterText, getPreviousElementSibling, getScrollHeight, getScrollLeft, getScrollTop, getScrollWidth, getStyle, getTabIndex, getTagName, getTitle, getWebkitdropzone, getWebkitRegionOverflow, hasAttribute, hasAttributeNS, insertAdjacentElement, insertAdjacentHTML, insertAdjacentText, isContentEditable, isDraggable, isHidden, isSpellcheck, isTranslate, querySelector, querySelectorAll, removeAttribute, removeAttributeNode, removeAttributeNS, scrollByLines, scrollByPages, scrollIntoView, scrollIntoView, scrollIntoViewIfNeeded, scrollIntoViewIfNeeded, setAccessKey, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setClassName, setContentEditable, setDir, setDraggable, setHidden, setId, setInnerHTML, setInnerText, setLang, setOnabort, setOnbeforecopy, setOnbeforecut, setOnbeforepaste, setOnblur, setOnchange, setOnclick, setOncontextmenu, setOncopy, setOncut, setOndblclick, setOndrag, setOndragend, setOndragenter, setOndragleave, setOndragover, setOndragstart, setOndrop, setOnerror, setOnfocus, setOninput, setOninvalid, setOnkeydown, setOnkeypress, setOnkeyup, setOnload, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnmousewheel, setOnpaste, setOnreset, setOnscroll, setOnsearch, setOnselect, setOnselectstart, setOnsubmit, setOntouchcancel, setOntouchend, setOntouchmove, setOntouchstart, setOnwebkitfullscreenchange, setOnwebkitfullscreenerror, setOuterHTML, setOuterText, setScrollLeft, setScrollTop, setSpellcheck, setTabIndex, setTitle, setTranslate, setWebkitdropzone, webkitMatchesSelector, webkitRequestFullscreen, webkitRequestFullScreen
addEventListener, addEventListener, appendChild, cloneNode, compareDocumentPosition, contains, dispatchEvent, getAttributes, getBaseURI, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, removeEventListener, removeEventListener, replaceChild, setNodeValue, setPrefix, setTextContent
intAt, length
numberAt
public final boolean isAutofocus()
SelectElement
autofocus
HTML attribute, which indicates whether the control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form-associated element in a document can have this attribute specified.
HTML5
Requires Gecko 2.0isAutofocus
in interface SelectElement
public final void setAutofocus(boolean param_autofocus)
setAutofocus
in interface SelectElement
public final boolean isDisabled()
SelectElement
disabled
HTML attribute, which indicates whether the control is disabled. If it is disabled, it does not accept clicks.isDisabled
in interface SelectElement
public final void setDisabled(boolean param_disabled)
setDisabled
in interface SelectElement
public final JsFormElement getForm()
SelectElement
getForm
in interface SelectElement
public final JsNodeList getLabels()
SelectElement
getLabels
in interface SelectElement
public final int getLength()
SelectElement
<option>
elements in this select
element.getLength
in interface SelectElement
public final void setLength(int param_length)
setLength
in interface SelectElement
public final boolean isMultiple()
SelectElement
multiple
HTML attribute, whichindicates whether multiple items can be selected.isMultiple
in interface SelectElement
public final void setMultiple(boolean param_multiple)
setMultiple
in interface SelectElement
public final String getName()
SelectElement
name
HTML attribute, containing the name of this control used by servers and DOM search functions.getName
in interface SelectElement
public final void setName(String param_name)
setName
in interface SelectElement
public final JsHTMLOptionsCollection getOptions()
SelectElement
<option>
elements contained by this element. Read only.getOptions
in interface SelectElement
public final boolean isRequired()
SelectElement
required
HTML attribute, which indicates whether the user is required to select a value before submitting the form.
HTML5
Requires Gecko 2.0isRequired
in interface SelectElement
public final void setRequired(boolean param_required)
setRequired
in interface SelectElement
public final int getSelectedIndex()
SelectElement
<option>
element.getSelectedIndex
in interface SelectElement
public final void setSelectedIndex(int param_selectedIndex)
setSelectedIndex
in interface SelectElement
public final JsHTMLCollection getSelectedOptions()
SelectElement
getSelectedOptions
in interface SelectElement
public final int getSize()
SelectElement
size
HTML attribute, which contains the number of visible items in the control. The default is 1,
HTML5 unless multiple is true, in which case it is 4.getSize
in interface SelectElement
public final void setSize(int param_size)
setSize
in interface SelectElement
public final String getType()
SelectElement
select-multiple
; otherwise, it returns select-one
.Read only.getType
in interface SelectElement
public final String getValidationMessage()
SelectElement
getValidationMessage
in interface SelectElement
public final JsValidityState getValidity()
SelectElement
getValidity
in interface SelectElement
public final String getValue()
SelectElement
getValue
in interface SelectElement
public final void setValue(String param_value)
setValue
in interface SelectElement
public final boolean isWillValidate()
SelectElement
isWillValidate
in interface SelectElement
public final void add(Element element, Element before)
SelectElement
Adds an element to the collection of option
elements for this select
element.
element
before
Optional from Gecko 7.0
null
(or the index does not exist), the new element is appended to the end of the collection.var sel = document.createElement("select"); var opt1 = document.createElement("option"); var opt2 = document.createElement("option"); opt1.value = "1"; opt1.text = "Option: Value 1"; opt2.value = "2"; opt2.text = "Option: Value 2"; sel.add(opt1, null); sel.add(opt2, null); /* Produces the following, conceptually: <select> <option value="1">Option: Value 1</option> <option value="2">Option: Value 2</option> </select> /
From HTML5 and Gecko 7.0 the before parameter is optional. So the following is accepted.
... sel.add(opt1); sel.add(opt2); ...
var sel = document.getElementById("existingList"); var opt = document.createElement("option"); opt.value = "3"; opt.text = "Option: Value 3"; sel.add(opt, null); /* Takes the existing following select object: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="2">Option: Value 2</option> </select> And changes it to: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="2">Option: Value 2</option> <option value="3">Option: Value 3</option> </select> /
From HTML5 and Gecko 7.0 the before parameter is optional. So the following is accepted.
... sel.add(opt); ...
var sel = document.getElementById("existingList"); var opt = document.createElement("option"); opt.value = "3"; opt.text = "Option: Value 3"; sel.add(opt, sel.options[1]); /* Takes the existing following select object: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="2">Option: Value 2</option> </select> And changes it to: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="3">Option: Value 3</option> <option value="2">Option: Value 2</option> </select> /
add
in interface SelectElement
public final boolean checkValidity()
SelectElement
HTML5 Checks whether the element has any constraints and whether it satisfies them. If the element fails its constraints, the browser fires a cancelable invalid
event at the element (and returns false).
A false
value if the select
element is a candidate for constraint evaluation and it does not satisfy its constraints. Returns true if the element is not constrained, or if it satisfies its constraints.
checkValidity
in interface SelectElement
public final JsNode item(int index)
SelectElement
HTML5 Gets an item from the options collection for this select
element. You can also access an item by specifying the index in array-style brackets or parentheses, without calling this method explicitly.
index
The node at the specified index, or null
if such a node does not exist in the collection.
item
in interface SelectElement
public final JsNode namedItem(String name)
SelectElement
HTML5 Gets the item in the options collection with the specified name. The name string can match either the id or the name attribute of an option node. You can also access an item by specifying the name in array-style brackets or parentheses, without calling this method explicitly.
name
null
if there are no matches.NodeList
in tree order of nodes whose name or id attributes match the specified name.namedItem
in interface SelectElement
public final void remove(int index)
SelectElement
Removes the element at the specified index from the options collection for this select element.
index
var sel = document.getElementById("existingList"); sel.remove(1); /* Takes the existing following select object: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="2">Option: Value 2</option> <option value="3">Option: Value 3</option> </select> And changes it to: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="3">Option: Value 3</option> </select> /
remove
in interface SelectElement
public final void remove(OptionElement option)
SelectElement
Removes the element at the specified index from the options collection for this select element.
index
var sel = document.getElementById("existingList"); sel.remove(1); /* Takes the existing following select object: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="2">Option: Value 2</option> <option value="3">Option: Value 3</option> </select> And changes it to: <select id="existingList" name="existingList"> <option value="1">Option: Value 1</option> <option value="3">Option: Value 3</option> </select> /
remove
in interface SelectElement
public final void setCustomValidity(String error)
SelectElement
HTML5 only. Sets the custom validity message for the selection element to the specified message. Use the empty string to indicate that the element does not have a custom validity error.
error
setCustomValidity
in interface SelectElement
Copyright © 2016. All rights reserved.