Try this:
 
<TMPL_LOOP NAME=OCCUPATION_LOOP>
<option value="<TMPL_VAR NAME=VAL>" <TMPL_VAR NAME="SELECTED">><TMPL_VAR NAME=TEXT></option>
</TMPL_LOOP>
 
where the value of SELECTED is either 0 or 1 dependends on whether that item is selected. This should work for multiple select options too.
 
Zheng
--Original Message--
From:  Mark Fuller<mark.fuller@earthlink.net>
To:  <html-template-users@lists.sourceforge.net>
Subject:  [htmltmpl] Select/option How to set "selected"?
 
 
I am creating a select list where all the "option" content comes from a
mySQL table. The following works fine:

====================
Occupation: <select name="occupation">
<TMPL_LOOP NAME=OCCUPATION_LOOP>
<option value="<TMPL_VAR NAME=VAL>"><TMPL_VAR NAME=TEXT></option>
</TMPL_LOOP>
====================

How can I specify a row should be "selected"? The TMPL_VAR named "VAL" is a
numeric index. If I could use TMPL_IF and concatenate the value of "VAL", I
think it would work.

<TMPL_IF NAME="SEL"<TMPL_VAR NAME="VAL">>
selected
</TMPL_IF>

In my program I could set "$sel5 = 1".

Is there any way to do this?

Thanks,
Mark





-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Html-template-users mailing list
Html-template- users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users