Class: InputElementDDL

InputElementDDL

A drop-down-list object, not a true input but very similar.

new InputElementDDL(tag)

Parameters:
Name Type Description
tag string The name and id of the SELECT for this object.
Source:
Example
languageDDL = new InputElementDDL('ddlLanguage');

Methods

addOption()

Adds a single option to a drop-down-list. Uses the standard JavaScript Option class, so takes the same argument list. If no value is specified, the text argument is used as the value.
Source:
Example
languageTable.addOption('French','FR');

addOptionList(list)

Adds a list of strings to a drop-down-list as options. These will have no specified values.
Parameters:
Name Type Description
list Array.<string> An array of strings to become list options
Source:
Example
languageTable.addOptionList(myList);

appendTo(parent)

Appends the drop-down-list and any label to a DOM node
Parameters:
Name Type Description
parent Object The DOM element to which this is added
Source:

disable()

Disables the DDL object
Source:

enable()

Enables the DDL object
Source:

getGUI()

Since this does not have a corresponding input, have an explicit method
Source:

getOption(index) → {object}

Return an object representing an option specified by its index
Parameters:
Name Type Description
index number The index of the requested option
Source:
Returns:
An object containing the value and text of the requested option or null
Type
object

getRowCount() → {number}

Return the number of options in the list.
Source:
Returns:
The option count.
Type
number

getSelectedRow() → {number}

Return the index of the currently selected row. Follows usual rules for HTML selectedIndex.
Source:
Returns:
Index corresponding to the selected (or first selected) row.
Type
number

getSelectedValue() → {number}

Return the value of the currently selected row, or null if none selected. DEPRECATED: use getValue() instead.
Source:
Returns:
Value corresponding to the selected (or first selected) row.
Type
number

getValue() → {String|null}

Return the value of the currently selected row, or null if none selected.
Source:
Returns:
Value corresponding to the selected (or first selected) row.
Type
String | null

select(ix)

Sets the selected index of a drop-down list. Less meaningful if it is a multi-select.
Parameters:
Name Type Description
ix number The index to select
Source:

selectByValue(find)

Causes the option whose value is specified to become the currently selected option
Parameters:
Name Type Description
find string The value of the option to make selected
Source:
Example
languageTable.selectByValue('French');

setAttribute(name, value)

Add an HTML attribute to the object, in this case to the SELECT element. If the attribute is "multiple", remember it for changed behavior.
Parameters:
Name Type Description
name string The name of the attribute
value string The value of the attribute
Source:
Example
mySelect.setAttribute("multiple","true");

setLabel(text)

Sets the text for the associated label.
Parameters:
Name Type Description
text string The label for this object.
Source:

setTextAlign(text)

Sets the text alignment for the associated label. Default is left.
Parameters:
Name Type Description
text string Should be either 'left' or 'right', depending on where you want the label.
Source: