Re-Selecting values in multi-select menu

P

PW

I use a multi-select menu in an ASP so the user can pick several values.

<select multiple name="lbErrorType" size="12">

However, after I have saved the records to the DB, and the user comes back
to edit a prior record, I re-populate the multiple select box and do a
"<option selected>" for each record that is saved to the DB.

<option selected>

But only the last value is selected !?!?

How do I get the select menu to select ALL the appropriate values ?
 
B

Bob Lehmann

How are you doing your "<option selected>" now !?!?

Also, for my own edification, what does "lb" in lbErrorType stand for?

Bob Lehmann
 
P

PW

Bob Lehmann said:
How are you doing your "<option selected>" now !?!?
Also, for my own edification, what does "lb" in lbErrorType stand for?


the "lb" just stabds for "listbox", a term from other languages I have used
in the past.

Heres the code snippet I am working on ... (rs1 is another result set that
is open and contains the matching error types to be selected)

<%
mySQL = "Select ErrorType from ErrorType order by ErrorType"
rs2.open mySQL,myDSN
%>
<select multiple name="lbErrorType" size="12">
<%Do While Not rs2.EOF%>
<%if rs1("ErrorType") = rs2("ErrorType") then%>
<option selected>
<%=rs2("ErrorType")%>
</option>
<%rs1.MoveNext%>
<%else%>
<option>
<%=rs2("ErrorType")%>
</option>
<%end if%>
<%rs2.MoveNext%>
<%Loop%>
</select>
<%
rs2.Close
Set rs2 = Nothing
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,891
Members
47,423
Latest member
henerygril

Latest Threads

Top