如何将数据库的数据填到radio和checkbox里?
shijuan = Request("Lesson")
SQL = "SELECT * FROM "& shijuan &" ORDER BY 题号"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &_
Server.MapPath("database/试题.mdb")
Set rs = conn.Execute( sql )
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &_
Server.MapPath("database/试卷.mdb")
%>
<HTML> <BODY BGCOLOR=BEIGE>
<CENTER>
<H1><FONT COLOR=#6699DD>在线考试系统</FONT></H1></CENTER>
<H2>考试科目 -- <%=shijuan%><HR></H2>
<%
'循环产生题目的信息
While Not rs.EOF
%>
<B><%=rs("题号")%>. <%=Server.HTMLEncode(rs("题目"))%>
(<%=rs("类型")%>:<%=rs("分值")%>分)</B>
<div>
<%
'得到选择题的四个选项
sql = "select * from "&session("num")&" where 编号="&rs("题号")
set rsno = server.createobject("adodb.recordset")
rsno.open sql,conn1,1,1
doc = Split(rsno(shijuan),", ")
For I=1 To 4
If rs("类型") = "单选" Then
TestType = "Radio"
%>
<INPUT Type=<%=TestType%> Name=No<%=rs("题号")%> Value=<% =I %>
<% if rsno(shijuan) = I %>checked<% end if %> ><%=Server.HTMLEncode(rs("选项" & I))%><BR>
<%
Else
TestType = "CheckBox"
%>
<INPUT Type=<%=TestType%> Name=No<%=rs("题号")%> Value=<% =I %>
<% if rsno(shijuan) = I then %> checked <% end if %> ><%=Server.HTMLEncode(rs("选项" & I))%><BR>
<% End If
Next
Response.Write "</div>"
rs.MoveNext
Wend
%>
单选框和复选框部分麻烦各位帮着看看,我只做了单选框部分可是为什么我从数据库读出来的值和I的值已经一样了还是不能选中啊....求解....望大神们火速解答~感激不尽~
<HR> </BODY> </HTML>
------解决方案--------------------
拿字段的值与input的值作比较
如果一直就 checked
<input type="radio" value="1" <%if rs("test") = "1" then%>checked="checked"<%end if%> />