複選框用法

來源:互聯網
上載者:User
複選框

  <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>
  <title>Untitled document.lt;/title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  </head>
  
  <body>
  <%
  sql= "DELETE FROM class WHERE classid IN (" & Request.Form("id") & ")"
  conn.execute (sql)%>
  </body>
  </html>



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.