问题还没有解决.
为什么我这样写,结果全部不为checked呢?
其中要判断ck中是否包含ck1,如果包含则checked.
现在有一条记录是包含的,结果却不对.
<%
sql="select * from item"
Set mrs= Server.CreateObject("ADODB.Recordset")
set mrs=conn.execute(sql)
ck1=mrs("id")
function StrInList(ck1, ck)
if instr(ck, "|" & ck1 & "|") > 0 then
StrInList = true
else
StrInList = false
end if
end function
do while not mrs.eof
%>
<input type='checkbox' value='<%=mrs("id")%>' name='<%=mrs("item")%>' <%if strinlist(ck1,ck) then%>checked<%end if%>>
<%
mrs.movenext
loop
mrs.close
%>
'判断 str 是否在 strList 中, 假设字符串之间用 "|" 号分隔
function StrInList(str, strList)
if len(strList) = 0 then
StrInList = false
elseif instr(strList, "|") = 0 then
if strList = str then
StrInList = true
else
StrInList = false
end if
else
if instr(strList, str & "|") > 0 or instr(strList, "|" & str) > 0 then
StrInList = true
else
StrInList = false
end if
end if
end function