Class HTMLSelectElement

All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable

public class HTMLSelectElement extends HTMLElement
The JavaScript object for HtmlSelect.
See Also:
  • Field Details

    • optionsArray_

      private HTMLOptionsCollection optionsArray_
    • labels_

      private NodeList labels_
      "Live" labels collection; has to be a member to have equality (==) working.
  • Constructor Details

    • HTMLSelectElement

      public HTMLSelectElement()
      Creates an instance.
  • Method Details

    • jsConstructor

      public void jsConstructor()
      JavaScript constructor.
      Overrides:
      jsConstructor in class HTMLElement
    • initialize

      public void initialize()
      Initialize the object.
    • getDomNodeOrDie

      public HtmlSelect getDomNodeOrDie()
      Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.
      Overrides:
      getDomNodeOrDie in class HTMLElement
      Returns:
      the DOM node
    • remove

      public void remove(int index)
      Removes option at the specified index.
      Parameters:
      index - the index of the item to remove
    • add

      public void add(HTMLOptionElement newOptionObject, Object beforeOptionObject)
      Adds a new item to the list (optionally) before the specified item.
      Parameters:
      newOptionObject - the DomNode to insert
      beforeOptionObject - the DomNode to insert the previous element before (null if at end).
    • appendChild

      public Object appendChild(Object childObject)
      Adds a DOM node to the node.
      Overrides:
      appendChild in class Node
      Parameters:
      childObject - the node to add to this node
      Returns:
      the newly added child node
    • insertBeforeImpl

      public Object insertBeforeImpl(Object[] args)
      Add a DOM node as a child to this node before the referenced node. If the referenced node is null, append to the end.
      Overrides:
      insertBeforeImpl in class Node
      Parameters:
      args - the arguments
      Returns:
      the newly added child node
    • item

      public Object item(int index)
      Gets the item at the specified index.
      Parameters:
      index - the position of the option to retrieve
      Returns:
      the option
    • getType

      public String getType()
      Returns the type of this input.
      Returns:
      the type
    • getOptions

      public HTMLOptionsCollection getOptions()
      Returns the value of the options property.
      Returns:
      the options property
    • getSelectedIndex

      public int getSelectedIndex()
      Returns the value of the selectedIndex property.
      Returns:
      the selectedIndex property
    • setSelectedIndex

      public void setSelectedIndex(int index)
      Sets the value of the selectedIndex property.
      Parameters:
      index - the new value
    • getValue

      public String getValue()
      Returns the actual value of the selected Option.
      Overrides:
      getValue in class HTMLElement
      Returns:
      the value
    • getLength

      public int getLength()
      Returns the value of the length property.
      Returns:
      the length property
    • setLength

      public void setLength(int newLength)
      Removes options by reducing the length property.
      Parameters:
      newLength - the new length property value
    • get

      public Object get(int index, org.htmlunit.corejs.javascript.Scriptable start)
      Returns the specified indexed property.
      Specified by:
      get in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      get in class org.htmlunit.corejs.javascript.ScriptableObject
      Parameters:
      index - the index of the property
      start - the scriptable object that was originally queried for this property
      Returns:
      the property
    • put

      public void put(int index, org.htmlunit.corejs.javascript.Scriptable start, Object newValue)
      Sets the index property.
      Specified by:
      put in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      put in class org.htmlunit.corejs.javascript.ScriptableObject
      Parameters:
      index - the index
      start - the scriptable object that was originally invoked for this property
      newValue - the new value
    • setValue

      public void setValue(Object newValue)
      Selects the option with the specified value.
      Overrides:
      setValue in class HTMLElement
      Parameters:
      newValue - the value of the option to select
    • getSize

      public int getSize()
      Returns the size attribute.
      Returns:
      the size attribute
    • setSize

      public void setSize(String size)
      Sets the size attribute.
      Parameters:
      size - the size attribute
    • isMultiple

      public boolean isMultiple()
      Returns true if the multiple attribute is set.
      Returns:
      true if the multiple attribute is set
    • setMultiple

      public void setMultiple(boolean multiple)
      Sets or clears the multiple attribute.
      Parameters:
      multiple - true to set the multiple attribute, false to clear it
    • getLabels

      public NodeList getLabels()
      Returns the labels associated with the element.
      Returns:
      the labels associated with the element
    • isRequired

      public boolean isRequired()
      Returns the required property.
      Returns:
      the required property
    • setRequired

      public void setRequired(boolean required)
      Sets the required property.
      Parameters:
      required - the new value
    • getName

      public String getName()
      Returns the value of the JavaScript attribute name.
      Overrides:
      getName in class HTMLElement
      Returns:
      the value of this attribute
    • setName

      public void setName(String newName)
      Sets the value of the JavaScript attribute name.
      Overrides:
      setName in class HTMLElement
      Parameters:
      newName - the new name
    • isDisabled

      public boolean isDisabled()
      Returns true if this element is disabled. Overridden to modify browser configurations.
      Overrides:
      isDisabled in class HTMLElement
      Returns:
      true if this element is disabled
    • setDisabled

      public void setDisabled(boolean disabled)
      Sets whether or not to disable this element. Overridden to modify browser configurations.
      Overrides:
      setDisabled in class HTMLElement
      Parameters:
      disabled - True if this is to be disabled
    • getForm

      public HTMLFormElement getForm()
      Returns the value of the JavaScript form attribute.
      Overrides:
      getForm in class HTMLElement
      Returns:
      the value of the JavaScript form attribute
    • checkValidity

      public boolean checkValidity()
      Checks whether the element has any constraints and whether it satisfies them.
      Returns:
      if the element is valid
    • getValidity

      public ValidityState getValidity()
      Returns:
      a ValidityState with the validity states that this element is in.
    • getWillValidate

      public boolean getWillValidate()
      Returns:
      whether the element is a candidate for constraint validation
    • setCustomValidity

      public void setCustomValidity(String message)
      Sets the custom validity message for the element to the specified message.
      Parameters:
      message - the new message
    • iterator

      public org.htmlunit.corejs.javascript.Scriptable iterator()