HTML Select Element

author Timo A. Hummel

 Methods

Direct call of object as string will return it's generated markup.

__toString() : string
Inherited
inherited_from \cHTML::__toString()
inherited_from \cHTMLFormElement::__toString()
inherited_from \cHTMLSelectElement::__toString()

Returns

stringGenerated markup

_setContent: Sets the content of the object

_setContent($content) 
Inherited
inherited_from \cHTML::_setContent()
inherited_from \cHTMLFormElement::_setContent()
inherited_from \cHTMLSelectElement::_setContent()

Parameters

$content

string/object String with the content or an object to render.

Function addArticles.

addArticles(int $iIDCat, bool $bColored, bool $bArtOnline, string $sSpaces) : int

Adds articles to select box values.

Parameters

$iIDCat

int

idcat of the category to be listed

$bColored

bool

Add color information to option elements

$bArtOnline

bool

If true, only online articles will be added

$sSpaces

string

Just some "" to show data hierarchically (used in conjunction with addCategories)

Returns

intNumber of items added

Function addCategories.

addCategories(int $iMaxLevel, bool $bColored, bool $bCatVisible, bool $bCatPublic, bool $bWithArt, bool $bArtOnline) : int

Adds category elements (optionally including articles) to select box values. Note: Using "with articles" adds the articles also - but the categories will get a negative value! There is no way to distinguish between a category id and an article id...

Parameters

$iMaxLevel

int

Max. level shown (to be exact: except this level)

$bColored

bool

Add color information to option elements

$bCatVisible

bool

If true, only add idcat as value, if cat is visible

$bCatPublic

bool

If true, only add idcat as value, if cat is public

$bWithArt

bool

Add also articles per category

$bArtOnline

bool

If true, show only online articles

Returns

intNumber of items added

Adds an cHTMLOptionElement to the number of choices.

addOptionElement($index, $element) : \none
Inherited
inherited_from \cHTMLSelectElement::addOptionElement()

Parameters

$index

string Index of the element

$element

object Filled cHTMLOptionElement to add

Returns

\none

addRequiredScript()

addRequiredScript($script) 
Inherited
inherited_from \cHTML::addRequiredScript()
inherited_from \cHTMLFormElement::addRequiredScript()
inherited_from \cHTMLSelectElement::addRequiredScript()

Parameters

$script

Function addTypesFromArt.

addTypesFromArt(int $iIDCatArt, string $sTypeRange) : int

Adds types and type ids which are available for the specified article

Parameters

$iIDCatArt

int

Article id

$sTypeRange

string

Komma separated list of Contenido type ids which may be in the resulting list (e.g. '1','17','28')

Returns

intNumber of items added

advances to the next ID available in the system.

advanceID() 
Inherited

This function is useful if you need to use HTML elements in a loop, but don't want to re-create new objects each time.

inherited_from \cHTML::advanceID()
inherited_from \cHTMLFormElement::advanceID()
inherited_from \cHTMLSelectElement::advanceID()

attachEventDefinition: Attaches the code for an event

attachEventDefinition($sName, $sEvent, $sCode) 
Inherited

Example to attach an onClick handler: setEventDefinition("foo", "onClick", "alert('foo');");

inherited_from \cHTML::attachEventDefinition()
inherited_from \cHTMLFormElement::attachEventDefinition()
inherited_from \cHTMLSelectElement::attachEventDefinition()

Parameters

$sName

string defines the name of the event

$sEvent

string defines the event (e.g. onClick)

$sCode

string defines the code

attachStyleDefinition: Attaches a style definition.

attachStyleDefinition($sName, $sDefinition) : string
Inherited

This function is not restricted to a single style, e.g. you can set multiple style definitions as-is to the handler.

$example->attachStyle("myIdentifier", "border: 1px solid black; white-space: nowrap"); $example->attachStyle("myIdentifier2", "padding: 0px");

Results in:

style="border: 1px solid black; white-space: nowrap; padding: 0px;"

inherited_from \cHTML::attachStyleDefinition()
inherited_from \cHTMLFormElement::attachStyleDefinition()
inherited_from \cHTMLSelectElement::attachStyleDefinition()

Parameters

$sName

string Name for a style definition

$sDefinition

string Definition for the given entity

Returns

stringfilled SGML closing skeleton

Automatically creates and fills cHTMLOptionElements

autoFill($stuff) : \none
Inherited

Array format: $stuff = array( array("value","title"), array("value","title"));

or regular key => value arrays.

inherited_from \cHTMLSelectElement::autoFill()

Parameters

$stuff

array Array with all items

Returns

\none

Constructor Function Initializes the SGML open/close tags

cHTML() 
Inherited
inherited_from \cHTML::cHTML()
inherited_from \cHTMLFormElement::cHTML()
inherited_from \cHTMLSelectElement::cHTML()

Constructor.

cHTMLFormElement($name, $id, $disabled, $tabindex, $accesskey) : \none
Inherited

This is a generic form element, where specific elements should be inherited from this class.

inherited_from \cHTMLFormElement::cHTMLFormElement()
inherited_from \cHTMLSelectElement::cHTMLFormElement()

Parameters

$name

string Name of the element

$id

string ID of the element

$disabled

string Item disabled flag (non-empty to set disabled)

$tabindex

string Tab index for form elements

$accesskey

string Key to access the field

Returns

\none

Constructor.

cHTMLInputSelectElement(string $sName, int $iWidth, string $sID, string $bDisabled, int $iTabIndex, $sAccessKey) : \none

Creates an HTML select field (aka "DropDown").

Parameters

$sName

string

Name of the element

$iWidth

int

Width of the select element

$sID

string

ID of the element

$bDisabled

string

Item disabled flag (non-empty to set disabled)

$iTabIndex

int

Tab index for form elements

$sAccessKey

Returns

\none

Constructor.

cHTMLSelectElement($name, $width, $id, $disabled, $tabindex, $accesskey) : \none
Inherited

Creates an HTML select field (aka "DropDown").

inherited_from \cHTMLSelectElement::cHTMLSelectElement()

Parameters

$name

string Name of the element

$width

int width of the select element

$id

string ID of the element

$disabled

string Item disabled flag (non-empty to set disabled)

$tabindex

string Tab index for form elements

$accesskey

string Key to access the field

Returns

\none

fillCloseSkeleton: Fills the close skeleton

fillCloseSkeleton() : string
Inherited
inherited_from \cHTML::fillCloseSkeleton()
inherited_from \cHTMLFormElement::fillCloseSkeleton()
inherited_from \cHTMLSelectElement::fillCloseSkeleton()

Returns

stringfilled SGML closer skeleton

fillSkeleton: Fills the open SGML tag skeleton

fillSkeleton($attributes) : string
Inherited

fillSkeleton fills the SGML opener tag with the specified attributes. Attributes need to be passed in the stringyfied variant.

inherited_from \cHTML::fillSkeleton()
inherited_from \cHTMLFormElement::fillSkeleton()
inherited_from \cHTMLSelectElement::fillSkeleton()

Parameters

$attributes

string Attributes to set

Returns

stringfilled SGML opener skeleton

Search for the selected elements

getDefault() : \Selected
Inherited
inherited_from \cHTMLSelectElement::getDefault()

Returns

\Selected"lvalue"

getID: returns the current ID

getID() : string
Inherited
inherited_from \cHTML::getID()
inherited_from \cHTMLFormElement::getID()
inherited_from \cHTMLSelectElement::getID()

Returns

stringcurrent ID

render(): Alias for toHtml

render() : string
Inherited
inherited_from \cHTML::render()
inherited_from \cHTMLFormElement::render()
inherited_from \cHTMLSelectElement::render()

Returns

stringRendered HTML

sets the access key for this element.

setAccessKey($accesskey) : \none
Inherited
inherited_from \cHTMLFormElement::setAccessKey()
inherited_from \cHTMLSelectElement::setAccessKey()

Parameters

$accesskey

string The length of the access key. May be A-Z and 0-9.

Returns

\none

setAlt: sets the alt and title attributes

setAlt($alt) 
Inherited

Sets the "alt" and "title" tags. Usually, "alt" is used for accessibility and "title" for mouse overs.

To set the text for all browsers for mouse over, set "alt" and "title". IE behaves incorrectly and shows "alt" on mouse over. Mozilla browsers only show "title" as mouse over.

inherited_from \cHTML::setAlt()
inherited_from \cHTMLFormElement::setAlt()
inherited_from \cHTMLSelectElement::setAlt()

Parameters

$alt

string Text to set as the "alt" attribute

setAttribte: Sets a specific attribute

setAttribute($sAttributeName, $sValue) 
Inherited
inherited_from \cHTML::setAttribute()
inherited_from \cHTMLFormElement::setAttribute()
inherited_from \cHTMLSelectElement::setAttribute()

Parameters

$sAttributeName

string Name of the attribute

$sValue

string Value of the attribute

sets the CSS class

setClass($class) 
Inherited
inherited_from \cHTML::setClass()
inherited_from \cHTMLFormElement::setClass()
inherited_from \cHTMLSelectElement::setClass()

Parameters

$class

string Text to set as the "alt" attribute

setContentlessTag()

setContentlessTag($contentlessTag) 
Inherited
inherited_from \cHTML::setContentlessTag()
inherited_from \cHTMLFormElement::setContentlessTag()
inherited_from \cHTMLSelectElement::setContentlessTag()

Parameters

$contentlessTag

Sets a specific cHTMLOptionElement to the selected state.

setDefault($lvalue) : \none
Inherited
inherited_from \cHTMLSelectElement::setDefault()

Parameters

$lvalue

string Specifies the "value" of the cHTMLOptionElement to set

Returns

\none

Sets the "disabled" attribute of an element.

setDisabled($disabled) : \none
Inherited

User Agents usually are showing the element as "greyed-out".

Example: $obj->setDisabled("disabled"); $obj->setDisabled("");

The first example sets the disabled flag, the second one removes the disabled flag.

inherited_from \cHTMLFormElement::setDisabled()
inherited_from \cHTMLSelectElement::setDisabled()

Parameters

$disabled

string Sets the disabled-flag if non-empty

Returns

\none

adds an "onXXX" javascript event handler

setEvent($event, $action) 
Inherited

example: $item->setEvent("change","document.forms[0].submit");

inherited_from \cHTML::setEvent()
inherited_from \cHTMLFormElement::setEvent()
inherited_from \cHTMLSelectElement::setEvent()

Parameters

$event

string Type of the event

$action

string Function or action to call (JavaScript Code)

Setter for static $_generateXHTML property

setGenerateXHTML(bool $value) 
InheritedStatic
inherited_from \cHTML::setGenerateXHTML()
inherited_from \cHTMLFormElement::setGenerateXHTML()
inherited_from \cHTMLSelectElement::setGenerateXHTML()

Parameters

$value

bool

sets the ID class

setID($id) 
Inherited
inherited_from \cHTML::setID()
inherited_from \cHTMLFormElement::setID()
inherited_from \cHTMLSelectElement::setID()

Parameters

$id

setMultiselect()

setMultiselect() 
Inherited
inherited_from \cHTMLSelectElement::setMultiselect()

Selects specified elements as selected

setSelected(array $aElements) : \none

Parameters

$aElements

array

Array with "values" of the cHTMLOptionElement to set

Returns

\none

setSize()

setSize($size) 
Inherited
inherited_from \cHTMLSelectElement::setSize()

Parameters

$size

sets the CSS style

setStyle($style) 
Inherited
inherited_from \cHTML::setStyle()
inherited_from \cHTMLFormElement::setStyle()
inherited_from \cHTMLSelectElement::setStyle()

Parameters

$style

addStyleDefinition

setStyleDefinition($entity, $definition) : string
Inherited
inherited_from \cHTML::setStyleDefinition()
inherited_from \cHTMLFormElement::setStyleDefinition()
inherited_from \cHTMLSelectElement::setStyleDefinition()

Parameters

$entity

string Entity to define

$definition

string Definition for the given entity

Returns

stringfilled SGML closing skeleton

sets the tab index for this element.

setTabindex($tabindex) : \none
Inherited

The tab index needs to be numeric, bigger than 0 and smaller than 32767.

inherited_from \cHTMLFormElement::setTabindex()
inherited_from \cHTMLSelectElement::setTabindex()

Parameters

$tabindex

int desired tab index

Returns

\none

Renders the output If the tag

toHTML() 
Inherited
inherited_from \cHTML::toHTML()
inherited_from \cHTMLFormElement::toHTML()
inherited_from \cHTMLSelectElement::toHTML()

Renders the select box

toHtml() : string
Inherited
inherited_from \cHTMLSelectElement::toHtml()

Returns

stringRendered HTML

removes an event handler

unsetEvent($event) 
Inherited

example: $item->unsetEvent("change");

inherited_from \cHTML::unsetEvent()
inherited_from \cHTMLFormElement::unsetEvent()
inherited_from \cHTMLSelectElement::unsetEvent()

Parameters

$event

string Type of the event

 Properties

 

$_aEventDefinitions 
Inherited
inherited_from \cHTML::$$_aEventDefinitions
inherited_from \cHTMLFormElement::$$_aEventDefinitions
inherited_from \cHTMLSelectElement::$$_aEventDefinitions
 

$_aStyleDefinitions 
Inherited
inherited_from \cHTML::$$_aStyleDefinitions
inherited_from \cHTMLFormElement::$$_aStyleDefinitions
inherited_from \cHTMLSelectElement::$$_aStyleDefinitions
 

$_content 
Inherited
inherited_from \cHTML::$$_content
inherited_from \cHTMLFormElement::$$_content
inherited_from \cHTMLSelectElement::$$_content
 

$_contentlessTag : boolean
Inherited
access private
inherited_from \cHTML::$$_contentlessTag
inherited_from \cHTMLFormElement::$$_contentlessTag
inherited_from \cHTMLSelectElement::$$_contentlessTag
 

$_options : array
Inherited
inherited_from \cHTMLSelectElement::$$_options
 

$_requiredScripts : array
Inherited
access private
inherited_from \cHTML::$$_requiredScripts
inherited_from \cHTMLFormElement::$$_requiredScripts
inherited_from \cHTMLSelectElement::$$_requiredScripts
 

$_skeleton_close : string
Inherited
access private
inherited_from \cHTML::$$_skeleton_close
inherited_from \cHTMLFormElement::$$_skeleton_close
inherited_from \cHTMLSelectElement::$$_skeleton_close
 

$_skeleton_open : string
Inherited
access private
inherited_from \cHTML::$$_skeleton_open
inherited_from \cHTMLFormElement::$$_skeleton_open
inherited_from \cHTMLSelectElement::$$_skeleton_open
 

$_skeleton_single : string
Inherited
access private
inherited_from \cHTML::$$_skeleton_single
inherited_from \cHTMLFormElement::$$_skeleton_single
inherited_from \cHTMLSelectElement::$$_skeleton_single
 

$_styledefs : string
Inherited
access private
inherited_from \cHTML::$$_styledefs
inherited_from \cHTMLFormElement::$$_styledefs
inherited_from \cHTMLSelectElement::$$_styledefs
 

$_tag : string
Inherited
access private
inherited_from \cHTML::$$_tag
inherited_from \cHTMLFormElement::$$_tag
inherited_from \cHTMLSelectElement::$$_tag