You can't use Response.Write in templates, only in scripts. Templates are evaluated and the Response object refers to the main output stream that the
entire result document is fed into. This would result in any Response output going in front of the document.
You can do it in script code, because the Response object is overlooaded for use in the script page there. You can SCAN trhough the document as needed like this:
< SELECT name="cmbCombo">
< %
select key, caption from Lookups where type = "lookup" into cursor TQuery
SCAN
% >
< OPTION value="< %= TQuery.key % >" >< %= Tquery.Caption % >
<% ENDSCAN %>
< /SELECT >
In a template, you can't use this syntax because compound statements can't be split up. But you can do this:
< %
lcOutput = ""
select key, caption from Lookups where type = "lookup" into cursor TQuery
SCAN
lcOutput = lcOutput + [< OPTION value="] + TQuery.key + ;
[" >] + Tquery.Caption
ENDSCAN
lcOutput = lcOutput + "< /select >"
RETURN lcOutput
% >
Here you're using a codeblock and the return value is embedded into the document. You could also use a UDF():
< %= GenerateList() % >
or an object. In fact, for generating combo boxes look into the wwDBFPopup object which generates the popup with a few property settings.
+++ Rick ---
>Hi!
>
>My codes seem not to be a problem when it's running but when I need a dynamic combobox (I generate the combobox with a SCAN and a cursor) in my web page, I have to put response.write command for all DHTML code lines to retreive Option value marker under the Select marker relative of the combobox. Otherwise the Option value markers appears on the top of the DHTML code (before de HEAD marker).
>
>Is there another best way to evitate to use many response.write commands and keep the order of my code when I do view source ?
>
>(I tried to send an example code but too many special caracters prevent me to go on)
>
>Regards