SelectBox
string SelectBox( string name, CDBResult values, string default = "", string selected = "", string add_to_tag = "class=\"typeselect\"" );
The function returns the HTML code of select tag (dropdown single selection list) with options from the CDBResult class object.
Function parameters
Parameter | Description |
---|---|
name | Tag name: <sel ect name="name" ... > |
values | List items. CDBResult type object, containing set of records, each having the following two fields: "REFERENCE_ID" (list item value) and "REFERENCE" (list item title). |
default | Title of the default item. This item has a value of "NOT_REF".
Optional. The default value is "" (do not add this item). |
selected | Selected item. The value of this parameter is matched against fields "REFERENCE_ID" of the values records. The field (list item) that is equal to selected becomes selected in the list. Optional parameter. The default value is "". |
add_to_tag | Arbitrary HTML code to be added to tag: <sel ect add_to_tag ... > Optional parameter. By default - "class=\"typeselect\"". |
See Also
Example of use
<? // create selection fr om the groups table $strSql = " SELECT G.ID as REFERENCE_ID, G.NAME as REFERENCE FR OM b_group G "; $rs = $DB->Query($strSql, false, "FILE: ".__FILE__."<br>LINE: ".__LINE__); // display the dropdown groups list echo SelectBox("GROUP", $rs, "< select group >", $GROUP, "class =\"inputselect\""); ?>
© «Bitrix24», 2001-2024