当前位置: 首页 > 图文教程 > 网络编程 > ASP > 复选框用法

ASP
asp中利用数组实现数据库记录的批量录入方法
vbs(asp)的栈类
加密處理使密碼更安全[CFS編碼加密]
在asp中通过vbs类实现rsa加密与解密
披著羊皮的大野狼 - Session
简体中文编码对应器
len(),lift(),right()不能正常识别中文的解决方法
实现WEB中的@虚拟域名系统(原理篇)
巧用ASP生成PDF文件
二级域名原理以及程序,申请即可开通
无组件上传图片到数据库中,最完整解决方案
在ASP中使用SQL语句之1:SELECT 语句
在ASP中使用SQL语句之2:用WHERE子句设置查询条件
在ASP中使用SQL语句之3:LIKE、NOT LIKE和 BETWEEN
在ASP中使用SQL语句之4:联合语句
在ASP中使用SQL语句之5:开始执行
在ASP中使用SQL语句之6:存储查询
在ASP中使用SQL语句之7:ORDER BY
在ASP中使用SQL语句之8:随机数
在ASP中使用SQL语句之9:表单操作

ASP 中的 复选框用法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 50 ::
收藏到网摘: n/a

       <input type="checkbox" name="checkbox" value="a">
  <input type="checkbox" name="checkbox" value="b">
  <input type="checkbox" name="checkbox" value="c">
  <input type="checkbox" name="checkbox" value="d">
  
  以这个为例,复选框的NAME属性都是相同的,这样就创建了一个控件数组,当传回后台时,是把选中的CHECKBOX按顺序用","连接起来,假如我们选中了B和C,那么用
  Response.write Request("checkbox")返回的就是b,c
  
  可以使用Split来分离成数组,例如
  bb=Split(Request("checkbox"))
  for each b in bb
  Response.write b
  next
  
  这样显示出来的就是选中的CHECKBOX的value了
  
  事例:多向删除!
  测试通过
  <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  
  <!--#include file="conn.asp"-->
  <%
  set rs=server.CreateObject("adodb.recordset")
  sql="select * from class order by date desc"
  rs.open sql,conn,1,1
  if rs.eof then
  response.Write("没有班级")
  response.end
  end if
  
  %>
  <html>
  <head>
  <title>Untitled document.lt;/title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  <link href="../css/fe.css" rel="stylesheet" type="text/css">
  </head>
  <script >
  function yesno()
   {
   return confirm("将会把所有成员及留言信息删除,您确定要删除该班级吗?");
   }
   </script>
  
  <body leftmargin="0" topmargin="0">
  
  
  <table width="500" border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td width="50" height="20" align="center">I D</td>
  <td height="20" align="center">班 级 名 称</td>
  <td width="100" height="20" align="center">注 册 日 期</td>
  <td height="20" align="center">人 数</td>
  <td align="center">删 除?</td>
  </tr>
  <%
  while not rs.eof
  %>
  <form name="form2" method="post" action="dec.asp"><tr>
  <td width="50" height="20" align="center">
  <input type="checkbox" name="id" value="<%=rs("classid")%>">
  </td>
  <td width="250" height="20" align="center"><%=rs("classname")%></td>
  <td width="100" align="center"><%=rs("date")%></td>
  <td width="50" height="20" align="center"><%=rs("num")%></td>
  <td width="50" height="20" align="center"></td>
  </tr><%rs.movenext
  wend
  rs.close
  set rs=nothing
  conn.close
  set conn=nothing
  %>
  <tr>
  <td height="20" align="center"> </td>
  <td height="20" align="center"> </td>
  <td align="center"> </td>
  <td height="20" align="center"> </td>
  <td height="20" align="center">
  <input type="submit" name="Submit" value="删除"></form>
  </td>
  </tr>
  
  </table>
  
  </body>
  </html>
  
  dec.asp
  
  
  <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  <!--#include file="conn.asp"-->
  <html>
  <head> <