[thelist] Auto-Selecting Multiple Select with ASP 2.0?
James Aylard
evolt at pixelwright.com
Thu Oct 23 13:21:11 CDT 2003
Rob Smith wrote:
> <select name="members" size="5" multiple>
> <%
> members = split(MyProject.fields.item("Members").value,",")
> count_members = uBound(members)
> while not People.eof
> response.write("<option value=""" &
> People.fields.item("userName").value & """")
> for x = 0 to count_members
> if People.fields.item("userName").value = members(x) then
> response.write (" Selected")
> end if
> next
> response.write(">" & People.fields.item("FirstName").value & "
> " & People.fields.item("LastName").value & "</option>")
> People.movenext
> wend
> %>
> </select>
>
> This works great, but only selects the first name in the series. It
> completely ignores: DMC\janedoe, DMC\barney.
>
> Anyone have any idea as to why?
Each successive value in your members array will have a space at the
start of the value. Instead of splitting on the comma alone, split on ", ".
Also, I strongly recommend assigning your field values to variables so
that you are only pulling them from the recordset once.
hth,
James Aylard
More information about the thelist
mailing list