首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

复选框写入数据库有关问题

2012-02-25 
复选框写入数据库问题表ssss列aabbXX值1XX值3口值1(选中)口值2口值3(选中)请问如何写入数据库?问2当读取数

复选框写入数据库问题
表ssss
列   aa         bb
      XX         值1
      XX         值3


口值1(选中)     口值2       口值3(选中)
请问如何写入数据库?


问2
当读取数据库输出的时候判断数据是否有值,对应输出
口值1(选中)     口值2       口值3(选中)

[解决办法]
记录:添加个FORM 提交SAVE
if request( "值1 ")=1 then
rs( "值1 ")=1
else
rs( "值1 ")=0
end if
if request( "值2 ")=1 then
rs( "值2 ")=1
else
rs( "值2 ")=0
end if

if request( "值3 ")=1 then
rs( "值3 ")=1
else
rs( "值3 ")=0
end if


返回:

<input name= "值1 " type= "checkbox " id= "值1 " value= "1 " <%if rs1( "值1 ")=1 then%> checked <%end if%> > 值1 
<input name= "值2 " type= "checkbox " id= "值2 " value= "1 " <%if rs1( "值2 ")=1 then%> checked <%end if%> >
值2
<input name= "值3 " type= "checkbox " id= "值3 " value= "1 " <%if rs1( "值3 ")=1 then%> checked <%end if%> > 值3
[解决办法]
Dim i
i=起始值 to 总数
If trim(Request.Form( "字段名 "&i))=1
then
正确的结果
Else
Trim(Request.Form( "字段名 "&i))=0
End If
[解决办法]
写入数据库:
<input type="checkbox" name="chk" value="值一">值一
<input type="checkbox" name="chk" value="值二">值二
<input type="checkbox" name="chk" value="值三">值三
提交:rs("bb")=trim(request("chk"))

输出:
if instr(rs("bb"),",")>0 then
idarr=split(rs("bb"),",")

else

end if
用数组循环对比,

热点排行