checkbox的事件问题!(接着那个在线练习程序的)

letviva 2005-07-07 07:58:30
http://community.csdn.net/Expert/topic/4125/4125351.xml?temp=.354458
跟这个帖子是说的一个事,不过那个已经结帖了

我想再追加一个问题,这个演示地址是:http://www.ry999.com/gb/d.asp

现在的问题就是我按页面最下边的按钮,checkbox可以全部勾上,但是不显示答案,一个一个的按就显示
所以想请问一下解决办法.这里再次感谢phuson(stone),itera(不容置疑) 和那些热心的朋友们!

上面演示的所有代码如下:
说明一点,<SCRIPT
src="img/Yxjs.gif"></SCRIPT>

<SCRIPT
src="img/Yx-ck.jpg"></SCRIPT>
连接的两个图片是有猫腻的,其实里边是一段脚本.
=================================================================================

<script language="javascript">
function showadv(num){
if (document.getElementById("answer"+num).checked == true) {
document.getElementById("Tdiv"+num).style.display = "";

}else{
document.getElementById("Tdiv"+num).style.display = "none";
}
}
</script>
<link href="style.css" rel="stylesheet" type="text/css">
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("qi.mdb")
%>

<%
exec="select * from question"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
dim pagenum
dim e_page
e_page=20
rs.pagesize=e_page
if request.querystring("pagenum")="" or request.querystring("pagenum")=0 then
pagenum=1
else
pagenum=request.querystring("pagenum")
rs.absolutepage=trim(request.querystring("pagenum"))
end if
%>

<%
i=i+1
do while not rs.eof and e_page>0
%>
<style type="text/css">
<!--
.style1 {color: #CCCCFF}
-->
</style>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<SCRIPT
src="img/Yxjs.gif"></SCRIPT>

<SCRIPT
src="img/Yx-ck.jpg"></SCRIPT>
<form name="form1">
<tr>
<td width="2%"> </td>
<td width="98%"><table width="100%" border="0">
<tr>
<td width="3%"><div align="left"><img src="img/icon.jpg" width="28" height="28"></div></td>
<td width="2%"><div align="center"><font color="#009900"><%=rs("id")%></font></div></td>
<td width="95%"><font color="#009900"><%=rs("question")%> ( ) </font></td>
</tr>
</table></td>

<table width="100%" border="0">
<tr>
<td width="5%"> </td>
<td width="43%">A.<%=rs("ans1")%></td>
<td width="52%">B.<%=rs("ans2")%></td>
</tr>
<tr>
<td> </td>
<td>C.<%=rs("ans3")%></td>
<td>D.<%=rs("ans4")%></td>
</tr>
<tr>
<td> </td>
<td>E.<%=rs("ans5")%></td>
<td> </td>
</tr>
</table>
<div align="center">
<table width="100%" border="0">
<tr>
<td width="4%" height="38"><div align="left"></div></td>
<td width="46%">
<div align="left">
<input name="answer<%=i%>" type="checkbox" onclick="showadv(<%=i%>)">
<span class="style1"><font size="1">显示答案</font></span> </div></td><td width="50%"> </td>
</tr>
</table>
<Span id="Tdiv<%=i%>" style="display:none"><font color="#FF0000"><%=rs("ans")%> <font color="#9999CC" size="1">你做对了吗:)</font></font></Span>
</div>
</tr>

<hr align="left" width="750" size="1">
<br>
<%
e_page=e_page-1
rs.movenext
i=i+1
loop
%>
<INPUT name="chkall" type="button" onclick="CheckAll(this.form)" value=显示所有答案 >
</form>
<table width="732" align="left">
<td width="724"><div align="center"><font color="#000000">  </font>第<font color=#ff0000><%=pagenum%></font>页 <font color="#000000">
<%
for p=1 to rs.pagecount
response.write ("[")
response.write "<a href=d.asp?pagenum="&p&">"&p&"</a>"
response.write ("] ")
next
%>
</font>共<%=rs.pagecount%>页</div></td></table>


...全文
114 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
masm_silly 2005-07-07
  • 打赏
  • 举报
回复
这样,先加个函数:
function showall(){
var i;
for (i=1;i<21;i++){
document.getElementById("Tdiv"+i).style.display = "";
document.getElementById("answer"+i).checked=true;
}
}
然后再按钮上调用:
<INPUT name="chkall" type="button" onclick="showall();" value=显示所有答案 >
letviva 2005-07-07
  • 打赏
  • 举报
回复
OK 楼上太强了!!自信中蕴涵着实力!

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧