
public class JsSelectElement extends JsElement implements SelectElement
ALLOW_KEYBOARD_INPUTATTRIBUTE_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_NODESVG_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, webkitRequestFullScreenappendChild, 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, setTextContentaddEventListener, 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, setZoomAndPanat, at, intAt, intAt, length, numberAt, numberAt, setAt, setAt, setAt, setAt, setAt, setAtcast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toStringblur, 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, webkitRequestFullScreenaddEventListener, 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, setTextContentintAt, lengthnumberAtpublic final boolean isAutofocus()
SelectElementautofocus
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 SelectElementpublic final void setAutofocus(boolean param_autofocus)
setAutofocus in interface SelectElementpublic final boolean isDisabled()
SelectElementdisabled
HTML attribute, which indicates whether the control is disabled. If it is disabled, it does not accept clicks.isDisabled in interface SelectElementpublic final void setDisabled(boolean param_disabled)
setDisabled in interface SelectElementpublic final JsFormElement getForm()
SelectElementgetForm in interface SelectElementpublic final JsNodeList getLabels()
SelectElementgetLabels in interface SelectElementpublic final int getLength()
SelectElement<option>
elements in this select element.getLength in interface SelectElementpublic final void setLength(int param_length)
setLength in interface SelectElementpublic final boolean isMultiple()
SelectElementmultiple
HTML attribute, whichindicates whether multiple items can be selected.isMultiple in interface SelectElementpublic final void setMultiple(boolean param_multiple)
setMultiple in interface SelectElementpublic final String getName()
SelectElementname
HTML attribute, containing the name of this control used by servers and DOM search functions.getName in interface SelectElementpublic final void setName(String param_name)
setName in interface SelectElementpublic final JsHTMLOptionsCollection getOptions()
SelectElement<option>
elements contained by this element. Read only.getOptions in interface SelectElementpublic final boolean isRequired()
SelectElementrequired
HTML attribute, which indicates whether the user is required to select a value before submitting the form.
HTML5
Requires Gecko 2.0isRequired in interface SelectElementpublic final void setRequired(boolean param_required)
setRequired in interface SelectElementpublic final int getSelectedIndex()
SelectElement<option>
element.getSelectedIndex in interface SelectElementpublic final void setSelectedIndex(int param_selectedIndex)
setSelectedIndex in interface SelectElementpublic final JsHTMLCollection getSelectedOptions()
SelectElementgetSelectedOptions in interface SelectElementpublic final int getSize()
SelectElementsize
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 SelectElementpublic final void setSize(int param_size)
setSize in interface SelectElementpublic final String getType()
SelectElementselect-multiple; otherwise, it returns select-one.Read only.getType in interface SelectElementpublic final String getValidationMessage()
SelectElementgetValidationMessage in interface SelectElementpublic final JsValidityState getValidity()
SelectElementgetValidity in interface SelectElementpublic final String getValue()
SelectElementgetValue in interface SelectElementpublic final void setValue(String param_value)
setValue in interface SelectElementpublic final boolean isWillValidate()
SelectElementisWillValidate in interface SelectElementpublic final void add(Element element, Element before)
SelectElementAdds an element to the collection of option elements for this select element.
elementbefore
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 SelectElementpublic final boolean checkValidity()
SelectElementHTML5 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 SelectElementpublic final JsNode item(int index)
SelectElementHTML5 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.
indexThe node at the specified index, or null if such a node does not exist in the collection.
item in interface SelectElementpublic final JsNode namedItem(String name)
SelectElementHTML5 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.
namenull if there are no matches.NodeList
in tree order of nodes whose name or id attributes match the specified name.namedItem in interface SelectElementpublic final void remove(int index)
SelectElementRemoves the element at the specified index from the options collection for this select element.
indexvar 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 SelectElementpublic final void remove(OptionElement option)
SelectElementRemoves the element at the specified index from the options collection for this select element.
indexvar 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 SelectElementpublic final void setCustomValidity(String error)
SelectElementHTML5 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.
errorsetCustomValidity in interface SelectElementCopyright © 2016. All rights reserved.