{html_options} {html_options} is a custom function that creates html <select><option> group with provided data. It takes care of which item(s) are selected by default as well. Required attributes are values and output, unless you use options instead. Attribute Name Type Required Default Description values array Yes, unless using options attribute n/a an array of values for dropdown output array Yes, unless using options attribute n/a an array of output for dropdown selected string/array No empty the selected option element(s) options associative array Yes, unless using values and output n/a an associative array of values and output name string No empty name of select group If a given value is an array, it will treat it as an html <optgroup>, and display the groups. Recursion is supported with <optgroup>. All output is XHTML compatible. If the optional name attribute is given, the <select name="groupname"></select> tags will enclose the option list. Otherwise only the <option> list is generated. All parameters that are not in the list above are printed as name/value-pairs inside the <select> tag. They are ignored if the optional name is not given. {html_options} Example 1: assign('cust_ids', array(1000,1001,1002,1003)); $smarty->assign('cust_names', array( 'Joe Schmoe', 'Jack Smith', 'Jane Johnson', 'Charlie Brown')); $smarty->assign('customer_id', 1001); ?> ]]> Where template is: {html_options values=$cust_ids output=$cust_names selected=$customer_id} ]]> Example 2: assign('cust_options', array( 1000 => 'Joe Schmoe', 1001 => 'Jack Smith', 1002 => 'Jane Johnson', 1003 => 'Charlie Brown') ); $smarty->assign('customer_id', 1001); ?> ]]> where template is: Both the above examples will output: ]]> {html_options} - Database example (eg PEAR or ADODB): assign('contact_types',$db->getAssoc($sql)); $sql = 'select contact_id, name, email, contact_type_id from contacts where contact_id='.$contact_id; $smarty->assign('contact',$db->getRow($sql)); ?> ]]> where the template is: {html_options name='contact_type_type' options=$contact_types selected=$contact.type_id} ]]> See also {html_checkboxes} and {html_radios}