Documentation

SelectBoxMFromArray

string
SelectBoxMFromArray(
 string name,
 array 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 select multiple tag (dropdown list with selection of multiple reply options) based on the passed array.

Function parameters

ParameterDescription
name Tag name:
<select name="name" ... >
values List items. Array that has the following structure:
array(
    "REFERENCE" => 
        array(
            "Item title 1", 
            "Item title 2",
            ...
            ),
    "REFERENCE_ID" => 
        array(
            "Item value 1",
            "Item value 2",
            ...
            )
    )
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 "".
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

Example of use

<?
$arr = array(
    "REFERENCE" => // array of item titles
        array("Option 1", "Option 2", "Option 3"),
    "REFERENCE_ID" => // array of item values
        array(1, 2, 3)
    ); 
echo SelectBoxMFromArray("arrSEL[]", $arr, $arrSEL, "", false, 4, 
"class =\"inputselect\"");
?>


© «Bitrix24», 2001-2024
Up