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?
there are several ways to do this. I prefer simply constructing my sql in such a way that the selected value is identified
SELECT val, text, (if then else to return 'selected' or '') AS selected FROM table WHERE whatever...
then in my template...
<tmpl_loop occupations> <option value="<tmpl_var val>" <tmpl_var selected>> <tmpl_var text> </option> </tmpl_loop>
-------------------------------------------------------
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
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users