Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown list box entries offset by 1

Status
Not open for further replies.

ghalewood

Programmer
Nov 13, 2001
42
EU
I have the following code populating a dropdown listbox. The list box displays all records from "REG" except what should be the first one (Alphabetical order). When the first record is selected and the data saved, the "ALIAS" saved is the record missing as detailled above. This is also true when another selection in the list is made, always the previous record (in alpha order) is saved to the database. There is also a blank record at the end of the listbox. Can anyone help please.

<%
set outpostDB = Server.CreateObject(&quot;ADODB.Connection&quot;)
outpostDB.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; + Server.MapPath(&quot;\db\tribes.mdb&quot;) + &quot;;Persist Security Info=False&quot;
sqltext = &quot;select * from Reg ORDER BY Reg.Alias &quot;
set itemSet = outpostDB.Execute(sqlText)
%>
<% do while not itemSet.eof %>
<SELECT NAME=p_Member>
<%=itemSet(&quot;alias&quot;)%>
<OPTION VALUE=<%=itemSet(&quot;Alias&quot;)%>
<% itemSet.movenext %>
<% loop %>
</SELECT>
 
Try it like this. Notice that I put all your output into response.write()'s (personal preference), and I put the text of your option in between an opening and closing <option> tag (what was causing your problem).

<%
with response
.write(&quot;<select name=p_Member>&quot; & vbcr)
while not itemSet.eof
.write(&quot;<option value=&quot;&quot;&quot; & itemSet(&quot;alias&quot;) & &quot;&quot;&quot;>&quot;)
.write(itemSet(&quot;alias&quot;))
.write(&quot;</option>&quot; & vbcr)
itemSet.movenext
wend
.write(&quot;</select>&quot; & vbcr)
end with
%>

:)
paul
penny1.gif
penny1.gif
 
1. <% do while not itemSet.eof %>
2. <SELECT NAME=p_Member>
3. <%=itemSet(&quot;alias&quot;)%>
4. <OPTION VALUE=<%=itemSet(&quot;Alias&quot;)%>
5. <% itemSet.movenext %>
6. <% loop %>
7. </SELECT>

Line 3 should be after line 4.
As in you open an option tag, give it some text and then
close it. Although the option tag does not need to be
closed.
i.e. <a href=&quot;&quot;>dsafdashf</a>
and <option value=&quot;&quot;>sdfhas</option>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top