"Bruce" <br*****@hotmail.com> wrote in message
news:bh********************************@4ax.com...
For those of you using templates to keep your PHP and HTML code
separate.....
How do you handle a HTML Select statement when the initial option
selected needs to come from a database field?
With TemplateTamer, I usually have template along these lines:
<select name="optionChooser">
<!--NAME:OPTION-->
<option value="{OPTIONVALUE}" {OPTIONSELECTED}>{OPTIONNAME}</option>
<!--END:OPTION-->
</select>
And then in logic file:
foreach ($options as $optValue => $optName) {
if ($optValue == $selectedValue)
$selected = 'SELECTED';
else
$selected= '';
$opt[] = array(
'OPTIONVALUE' => $optValue ,
'OPTIONNAME' => $optName,
'OPTIONSELECTED'=> $selected
);
}
You can see more on that example at:
http://www.templatetamer.org/index.p...ListboxExample
rush
--
http://www.templatetamer.com/