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 returns the HTML code of
Function parameters
Parameter | Description |
---|---|
name | Tag name: <select name="name" ... > |
values | List items. The array 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 "". |
default | TItle of the list item, selected by default. This element value - "NOT_REF".
Optional parameter. By default - "" (do not add such item). |
add_to_tag | Arbitrary HTML code that will be added into the tag: <select add_to_tag ... > Optional parameter. By default - "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 parameter. The default value is false (do not submit). |
form_name | If parameter submit_form = true, this parameter contains the name of the form containing the <select> tag.
Optional parameter. The default value "form1". |
See Also
Example of use
<form name="form2" action="" method="GET"> <? $arr = array( "REFERENCE" => // array of item titles array("Option 1", "Option 2", "Option 3"), "REFERENCE_ID" => // array of item titles array(1, 2, 3) ); echo SelectBoxFromArray("CHOICE", $arr, $CHOICE, "", "", true, "form2") ?> </form>
© «Bitrix24», 2001-2024