复选框信息从数据表内提取
请问如何使复选框信息从数据表内提取显示,显示格式为按序号排序先排列左边,再排列右边,若数据条目数为奇数时,右侧排列项比左侧多一个。望高手指教
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <% checkitems="A,B,C,D,E,F,G,H,I" '复选框项目 checkresult="1,0,0,1,1,0,1,0,0" '选择的项目,1为选中 checkitems=split(checkitems,",") '转成数组 checkresult=split(checkresult,",") checkcount=ubound(checkitems)+1 '计算有多少个选项 firstcount=int(checkcount/2) '分两列,计算第一列的选项数 %> <%=firstcount%> / <%=checkcount%> <table border="1"> <tr><td> <% for i=1 to firstcount %> <input name="checkitem" type="checkbox" value="1"<%if checkresult(i-1)="1" then%> checked="checked"<%end if%>> <%=checkitems(i-1)%><br /> <% next %> </td><td> <% for i=firstcount+1 to checkcount %> <input name="checkitem" type="checkbox" value="1"<%if checkresult(i-1)="1" then%> checked="checked"<%end if%>> <%=checkitems(i-1)%><br /> <% next %> </td></tr> </table>不知道你的复选框结果是怎么保存,上面的代码是用1,0,0,1,1,0,1,0,0这样保存的
Dim i,j,col : i = 1 col = 2 '列数 Response.Write "<tr>" do while not rs.eof if i mod col = 0 Then Response.Write "</tr><tr>" Response.Write "<td><label><input type=""checkbox"" value="""&rs("id")&""" name=""check"" />" & rs("name") & "</label></td>" rs.MoveNext i = i + 1 loop If (i-1) Mod col > 0 Then For j = 0 To col - ((i-1) Mod col) Response.Write "<td> </td>" Next End If Response.Write "</tr>"