select 多选框读取数据库问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 04:40:51
在ASP中,读取数据库某一字段的内容
rs("fjman")里面的数据是:李先生,王小姐
如何让读取到的这两个内容项默认为选中?

代码如下:
<select name="sellman" size="5" multiple class="unnamed1" id="sellman">
<%
set rs1=conn.execute("select * from ywy where ting=1 and yglx='ywy' order by list asc") '读取全部人员
do while not rs1.eof
if rs1("ywy") = rs("fjman") then '这里该怎么写???????
%>
<option value="<%=rs1("ywy")%>" selected>:::<%=rs1("ywy")%>:::</option>
<%else%>
<option value="<%=rs1("ywy")%>">:::<%=rs1("ywy")%>:::</option>
<%end if
rs1.movenext
loop
rs1.close
%>

</select>

<select name="sellman" size="5" multiple class="unnamed1" id="sellman">
<%
set rs1=conn.execute("select * from ywy where ting=1 and yglx='ywy' order by list asc")
do while not rs1.eof
%>
<option value="<%=rs1("ywy")%>" <%if InStr(rs("fjman"),rs1("ywy"))>0 then Response.Write("selected")%> >:::<%=rs1("ywy")%>:::</option>
<%
rs1.movenext
loop
rs1.close
%>
</select>

试试这个~rs("fjman")包含多个sellman的值即是这样

<select name="sellman" size="5" multiple class="unnamed1" id="sellman">
<%
t = Trim(rs("fjman"))
set rs1=conn.execute("select * from ywy where ting=1 and yglx='ywy' order by list asc") '读取全部人员
do while not rs1.eof
'