综合以上,以下代码请帮我改进一下:
1、写入数据库:
dim limit
limit=request.form("choice")
'获取用户点选的项目id,也就是tree表中tree_name字段的id
limit=replace(limit," ","")
'替换掉空格
limit="|"&replace(limit,",","|")&"|"
'替换逗号为 |
'response.write limit的结果就是:|1|2|4|8|10|11|....|20|....
rs.open "select * from [user] where ....",conn,1,3
rs("choice")=limit
......
2、用户选择页面
dim effect,newid
...
rs1.open "select * from [user]",conn,1,1
effect=rs1("choice")
...
rs2.open "select id,tree_name from [tree]",conn,1,1
newid=rs2("id")
循环开始
<input name="choice" value="<%=newid%>" type=...<%if ...then response.write "checked" end if%>><%=rs2("tree_name")%> '意思是,如果user表的choice字段里有tree表中tree_name的ID,就为选中状态。
循环结束
如何写这个if语句?
if instr(effect,""&newid&"") then.....
补充:关键这个effect的值,它不是普通的字符串,而是tree_name的ID
[[it] 本帖最后由 nicechlk 于 2008-10-19 23:48 编辑 [/it]]