...

<select> object not building

RadarBob
07-19-2002, 07:38 PM
The following code is not executing the imbedded IF or the DO UNTIL that's supposed to build the options of the <select> object. Additionally the rest of the form beyond this point does not build at all. The <select> object below is the only form object that uses ASP. The recordset is being populated before getting here. Can you see any problems?


<tr>
<td border="3" valign="middle" align="center" width="-1" height="228">
Available Keywords<br><br>

<%
rsAllDBKeywords.MoveFirst()
%>
<!-- The list of existing keywords -->
<select size="14" name="oldList" width="300" multiple tabindex="1"
onKeyPress="return findOption(this)">
/////////// seems to work to this point only ///////////////////
<%
if rsAllDBKeywords.EOF then
%>
<option value="00">&lt;--empty--&gt;</option>
<%
else
Do until rsDBAllKeywords.EOF
%>
<option style="background-color:lightgrey"><%Response.write rsAllDBKeywords.fields("Keyword").value%> </option>
<%
rsAllDBKeywords.MoveNext()
loop
end if

allida77
07-22-2002, 04:45 PM
<option style="background-color:lightgrey"><%Response.write rsAllDBKeywords.fields("Keyword").value%> </option>

Try just:

<%Response.write rsAllDBKeywords.fields("Keyword")%>

I am not sure the ".value" is valid syntax.

RadarBob
07-22-2002, 08:03 PM
Well, I got it to work :thumbsup:

The trick is to use response.write to build the HTML lines.

rsAllDBKeywords.MoveFirst()

if rsAllDBKeywords.EOF then
response.write "<option value=""00"">&lt;--empty--&gt;</option>"
else
Do while not rsAllDBKeywords.EOF
response.write "<option style=""background-color:lightgrey"">" &
rsAllDBKeywords.fields("keyword").value & "</option>"
rsAllDBKeywords.MoveNext()
loop
end if

ReyN
07-22-2002, 09:52 PM
hi, this too should work:


<select name="whatever">
<% do until rs.EOF %>
<option><%= rs("fieldName")%>
<% rs.MoveNext
loop
'close options recset and flush from memory
rs.Close
set rs = Nothing %>
</select> :D

RadarBob
07-23-2002, 03:50 PM
ReyN;
What you're illustrating is what I first attempted as shown in my initial post; isn't it?

What seems to be happening is that the <SELECT> bit gets executed -- the select box actually shows up -- but none of the <option>s get built.

While the looping technique you show works for stuffing data into table rows and cells, it doesn't seem to work for building <form> objects on the fly - at least not <select><option>.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum