Bitrix Site Manager

SelectBoxFromArray

string
SelectBoxFromArray(
 string name,
 array values,
 string selected = "",
 string default = "",
 string add_to_tag = "class=\"typeselect\"",
 bool submit_form = false,
 string form_name = "form1"
)

The function SelectBoxFromArray returns the HTML code of tag <select> built on the array data.

Parameters

ParameterDescription
name Tag name:
<select name="name" ... >
values List items. This array has the following format:
array(
    "REFERENCE" => 
        array(
            "Item title 1", 
            "Item title 2",
            ...
            ),
    "REFERENCE_ID" => 
        array(
            "Item title 1",
            "Item title 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. The default value is "".
default Title of the default item. This item has a value of "NOT_REF".
Optional. The default value is "" (do not add this item).
add_to_tag Arbitrary HTML code to be added to tag:
<select add_to_tag ... >
Optional. The default value is "class=\"typeselect\"".
submit_form If "true", the form with name form_name submits data when selection changes (a user selects an item in the list).
Optional. The default value is false (do not submit).
form_name If submit_form == true, this parameter contains the name of the form containing the tag <select>.
Optional. The default value is "form1".

See Also

Example



<form name="form2" action="" method="GET">
<?
$arr = array(
    "REFERENCE" => // array of item titles
        array("Choice 1", "Choice 2", "Choice 3"),
    "REFERENCE_ID" => // array of item values
        array(1, 2, 3)
    ); 
echo SelectBoxFromArray("CHOICE", $arr, $CHOICE, "", "", true, "form2")
?>
</form>