How to keep a specific value selected in a select HTML control in following scenario?
问题 I'm using PHP, Smarty and MySQL for my website. I'm having a select control. The code for it is as follows: <select name="contact_label" id="set_contact_label"> <option value=""> -- Select label-- </option> {if $enquiries_labels} {foreach from=$enquiries_labels item=label key=key} <option value="{$key}" {if $contact_label == $key} selected="selected" {/if}>{$label}</option> {/foreach} {/if} </select> Equivalent HTML output is as follows: <select name="contact_label" id="contact_label">