Represents a select box.

This is used to build HTML code by using objects.

package | metaHTML

### Methods

## Constructor.

    __construct(String $name, array $elements, array $selectedElements, int $size)

Examples:
$select = new htmlSelect('myName', array('value1', 'value2'), array('value1'));
$select = new htmlSelect('myName', array('label1' => 'value1', 'label2' => 'value2'), array('value1'));
$select->setHasDescriptiveElements(true);
$select = new htmlSelect('myName', array('optgroupLabel' => array('value1', 'value2')), array('value1'));
$select->setHasDescriptiveElements(true);
$select->setContainsOptgroups(true);

### Parameters

#### $name

`String`

element name

#### $elements

`array`

list of elements array(label => value) or array(value1, value2) or array('optgroup' => array(...))

#### $selectedElements

`array`

list of selected elements (optional, default none)

#### $size

`int`

size (optional, default = 1)

## Prints the HTML code for this element.

    generateHTML(string $module, array $input, array $values, boolean $restricted, integer $tabindex, string $scope) : array

### Parameters

#### $module

`string`

Name of account module

#### $input

`array`

List of meta-HTML elements

#### $values

`array`

List of values which override the defaults in $input (name => value)

#### $restricted

`boolean`

If true then no buttons will be displayed

#### $tabindex

`integer`

Start value of tabulator index for input fields

#### $scope

`string`

Account type

### Returns

`array`List of input field names and their type (name => type)

## Returns the HTML attributes for the alignment.

    getAlignmentString() : String

Inherited

inherited_from | \htmlElement::getAlignmentString()

### Returns

`String`alignment HTML attributes (e.g. align="right" valign="top")

## Returns the HTML attribute for the colspan.

    getColspanString() : String

Inherited

inherited_from | \htmlElement::getColspanString()

### Returns

`String`colspan HTML attribute (e.g. colspan=3)

## Returns the HTML attribute for the rowspan.

    getRowspanString() : String

Inherited

inherited_from | \htmlElement::getRowspanString()

### Returns

`String`rowspan HTML attribute (e.g. rowspan=3)

## Returns the CSS classes of the surrounding table cell for this element.

    getTableCellCSSClasses() : array

Inherited

inherited_from | \htmlElement::getTableCellCSSClasses()

### Returns

`array`CSS classes

## Adds CSS classes to this element.

    setCSSClasses(array $classes)

Inherited

inherited_from | \htmlElement::setCSSClasses()

### Parameters

#### $classes

`array`

CSS class names

## Specifies if the elements are divided into optgroups.

    setContainsOptgroups(boolean $containsOptgroups)

### Parameters

#### $containsOptgroups

`boolean`

activates optgroups

## Specifies if the elements are just a simple list or an assoziative array (default: simple list).

    setHasDescriptiveElements(boolean $hasDescriptiveElements)

### Parameters

#### $hasDescriptiveElements

`boolean`

activates descriptive elements

## Specifies if this component is enabled and accepts user modification.

    setIsEnabled(boolean $isEnabled)

### Parameters

#### $isEnabled

`boolean`

enabled if true

## Specifies if multi-selection is enabled (default: disabled).

    setMultiSelect(boolean $multiSelect)

### Parameters

#### $multiSelect

`boolean`

allows multi-selection

## Sets the JavaScript code for the onchange event.

    setOnchangeEvent(String $onchangeEvent)

### Parameters

#### $onchangeEvent

`String`

onchange event code (e.g. myfunction();)

## Specifies if the text direction should be set to right to left.

    setRightToLeftTextDirection(boolean $rightToLeftTextDirection)

### Parameters

#### $rightToLeftTextDirection

`boolean`

if true use right to left direction

## Specifies if the elemets should be sorted (default: sort).

    setSortElements(boolean $sortElements)

### Parameters

#### $sortElements

`boolean`

sort elements

## Adds CSS classes to the surrounding table cell for this element.

    setTableCellCSSClasses(array $classes)

Inherited

inherited_from | \htmlElement::setTableCellCSSClasses()

### Parameters

#### $classes

`array`

CSS class names

## This will hide the given table rows when the select is changed to the specified value.

    setTableRowsToHide(array $tableRowsToHide)

The given IDs can be of any e.g. input element. Starting from this element the first parent "

" element will be used to show/hide.
Example:
Using "mycheckbox" will use this "tr" to hide/show.
Example for $tableRowsToHide:
array('yes' => array('option1', 'option2'), 'no' => array('option3'))

### Parameters

#### $tableRowsToHide

`array`

array of select value => array of IDs of child elements to hide

## This will show the given table rows when the select is changed to the specified value.

    setTableRowsToShow(array $tableRowsToShow)

The given IDs can be of any e.g. input element. Starting from this element the first parent "

" element will be used to show/hide.
Example:
Using "mycheckbox" will use this "tr" to hide/show.
Example for $tableRowsToShow:
array('yes' => array('option1', 'option2'), 'no' => array('option3'))

### Parameters

#### $tableRowsToShow

`array`

array of select value => array of IDs of child elements to show

## Specifies if select boxes that contain only a single element should be transformed to a simple text field.

    setTransformSingleSelect(boolean $transformSingleSelect)

### Parameters

#### $transformSingleSelect

`boolean`

transform single options to text

## Specifies that the value should not be automatically saved when used in self service or server profile (default: false).

    setTransient(boolean $transient)

### Parameters

#### $transient

`boolean`

transient field

## Specifies the width of this selection box.

    setWidth(String $width)

### Parameters

#### $width

`String`

width (e.g. 20em)

## Creates the JavaScript code to hide/show table rows based on the select value.

    printCodeForShowHideTableRows(String $onChange)

### Parameters

#### $onChange

`String`

onChange code

## Prints the HTML code of the option tags.

    printOptionsHTML(array $elements)

### Parameters

#### $elements

`array`

list of options

### Properties

## alignment when inside a table

    $alignment

Inherited

inherited_from | \htmlElement::$$alignment

## colspan if inside a table

    $colspan

Inherited

inherited_from | \htmlElement::$$colspan

## rowspan if inside a table

    $rowspan

Inherited

inherited_from | \htmlElement::$$rowspan

## CSS classes

    $cssClasses

Inherited

inherited_from | \htmlElement::$$cssClasses

## table cell CSS classes

    $tableCellCssClasses

Inherited

inherited_from | \htmlElement::$$tableCellCssClasses

## list of enclosing table rows to hide when checked

    $tableRowsToHide

## list of enclosing table rows to show when checked

    $tableRowsToShow

## contains optgroups

    $containsOptgroups

## elements

    $elements

## descriptive elements

    $hasDescriptiveElements

## enabled or disabled

    $isEnabled

## allows multi-selection

    $multiSelect

## name of select field

    $name

## onchange event

    $onchangeEvent

## right to left text direction

    $rightToLeftTextDirection

## selected elements

    $selectedElements

## size

    $size

## sorting enabled

    $sortElements

## transform select boxes with one element to text

    $transformSingleSelect

## indicates that this field should not automatically be saved in the self service or server profile

    $transient

## width of input element

    $width

### Constants

## align to bottom

    ALIGN_BOTTOM

Inherited

inherited_from | \htmlElement::ALIGN_BOTTOM

## align to center

    ALIGN_CENTER

Inherited

inherited_from | \htmlElement::ALIGN_CENTER

## align to left

    ALIGN_LEFT

Inherited

inherited_from | \htmlElement::ALIGN_LEFT

## align to right

    ALIGN_RIGHT

Inherited

inherited_from | \htmlElement::ALIGN_RIGHT

## align to top

    ALIGN_TOP

Inherited

inherited_from | \htmlElement::ALIGN_TOP

## validation rule to allow only numbers ([0-9]+)

    VALIDATE_NUMERIC

Inherited

inherited_from | \htmlElement::VALIDATE_NUMERIC