Documentation

SelectBoxM

string
SelectBoxM(
 string name,
 CDBResult values,
 array selected,
 string top_element = "",
 bool select_top_element = false,
 int size = 5,
 string add_to_tag = "class=\"typeselect\""
);

The function returns the HTML code of the tag with options fr om the CDBResult class object.

Function parameters

ParameterDescription
name Tag name:
<sel ect name="name" ... >
values List items. CDBResult class object, containing set of records each having the following two fields: "REFERENCE_ID" (list item value) and "REFERENCE" (list item title).
selected Selected items. The values of this array are matched against fields "REFERENCE_ID" of the values records. Fields (list items) that are equal to selected values becomes selected in the list.
top_element Title of the special item that is always placed as the first in the list and that can be always optionally selected (defined by the select_top_element). This item has value - "NOT_REF".
Optional parameter. By default the value is "" (do not add such item).
select_top_element If true, the top_element item will be always selected.
Optional parameter. By default value is false (do not select).
size Field of ''size'' for ''select'' tag:
<select size="size" ... >
This parameter passes the number of visible lines in the dropdown multiple selection list. Optional parameter. By default value is 5.
add_to_tag Arbitrary HTML code that will be added into the tag:
<select add_to_tag ... >
Optional parameter. By default - "class=\"typeselect\"".

See Also

Examples 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
    WH ERE
        G.ID<>2 -- ''everybody'' group, containing all users by default
    ";
$rs = $DB->Query($strSql, false, "FILE: ".__FILE__."<br>LINE: ".__LINE__);

// display a list of groups with multiple selection
echo SelectBoxM("arrGROUP[]", $rs, $arrGROUP, "< the "everybody" group >", true, 20, 
"class =\"inputselect\"");
?>


© «Bitrix24», 2001-2024