jsp中實現批量刪除
阿新 • • 發佈:2019-02-12
<%@ page language="java" import="java.util.*,java.sql.*,com.it.bean.*" pageEncoding="utf-8"%>
<jsp:useBean id="common" class="com.it.bean.pageinfo" scope="page"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
var flag=1;
function selectAll(){
if(flag==1){
if(common_delete.selectdelete.length!=undefined){
for (var i=0;i <common_delete.selectdelete.length;i++)
common_delete.selectdelete[i].checked=true;
}else{
common_delete.selectdelete.checked=true;
}
flag=0;
}else{
if(common_delete.selectdelete.length!=undefined){
for (var i=0;i <common_delete.selectdelete.length;i++)
common_delete.chxSong[i].checked=false;
}else{
common_delete.selectdelete.checked=false;
}
flag=1;
}
}
</script>
</head>
<body>
<div align="center">
<div align="center">
<form name="common_delete" method="post" action="../CommonDeleteServlet">
<table bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#cc99cc">
<td width="10%" align="center"><input type= "button" name= "selall " value= "全選/反選 " onClick= "selectAll();"></td>
<td width="10%" align="center"><font face="華文隸書" size="4">編號</font></td>
<td width="10%" align="center"><font face="華文隸書" size="4">描述</font></td>
<td width="10%" align="center"><font face="華文隸書" size="4">所屬類</font></td>
<td width="20%" align="center"><font face="華文隸書" size="4">診斷</font></td>
<td width="10%" align="center"><font face="華文隸書" size="4">頻率</font></td>
</tr>
<%
int i=0;
String setcolor;
try
{
ResultSet rst1=common.getCommon("100");
while(rst1.next())
{
if(i%2==0)
setcolor="#ffffff";
else
setcolor="#D9D9D9";
%>
<tr bgcolor=<%=setcolor%>>
<td width="10%" align="center"><input type="checkbox" name="selectdelete" value="<%=rst1.getString(1).trim()%>"></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(1).trim()%></font></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(3).trim()%></font></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(2).trim()%></font></td>
<td width="20%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(4).trim()%></font></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getInt(6)%></font></td>
</tr>
<%
i++;
}
rst1.close();
}
catch(Exception e){}
%>
<tr><td colspan="3"> </td>
<td align="center">
<input type="submit" value="刪 除" onclick="return confirm('你確定所選?')"></td></tr>
</table>
</form>
</div>
</div>
</body>
</html>
<jsp:useBean id="common" class="com.it.bean.pageinfo" scope="page"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
var flag=1;
function selectAll(){
if(flag==1){
if(common_delete.selectdelete.length!=undefined){
for (var i=0;i <common_delete.selectdelete.length;i++)
common_delete.selectdelete[i].checked=true;
}else{
common_delete.selectdelete.checked=true;
}
flag=0;
}else{
if(common_delete.selectdelete.length!=undefined){
for (var i=0;i <common_delete.selectdelete.length;i++)
common_delete.chxSong[i].checked=false;
}else{
common_delete.selectdelete.checked=false;
}
flag=1;
}
}
</script>
</head>
<body>
<div align="center">
<div align="center">
<form name="common_delete" method="post" action="../CommonDeleteServlet">
<table bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#cc99cc">
<td width="10%" align="center"><input type= "button" name= "selall " value= "全選/反選 " onClick= "selectAll();"></td>
<td width="10%" align="center"><font face="華文隸書" size="4">編號</font></td>
<td width="10%" align="center"><font face="華文隸書" size="4">描述</font></td>
<td width="10%" align="center"><font face="華文隸書" size="4">所屬類</font></td>
<td width="20%" align="center"><font face="華文隸書" size="4">診斷</font></td>
<td width="10%" align="center"><font face="華文隸書" size="4">頻率</font></td>
</tr>
<%
int i=0;
String setcolor;
try
{
ResultSet rst1=common.getCommon("100");
while(rst1.next())
{
if(i%2==0)
setcolor="#ffffff";
else
setcolor="#D9D9D9";
%>
<tr bgcolor=<%=setcolor%>>
<td width="10%" align="center"><input type="checkbox" name="selectdelete" value="<%=rst1.getString(1).trim()%>"></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(1).trim()%></font></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(3).trim()%></font></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(2).trim()%></font></td>
<td width="20%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getString(4).trim()%></font></td>
<td width="10%" align="center"><font face="楷體_GB2312" size="3"><%=rst1.getInt(6)%></font></td>
</tr>
<%
i++;
}
rst1.close();
}
catch(Exception e){}
%>
<tr><td colspan="3"> </td>
<td align="center">
<input type="submit" value="刪 除" onclick="return confirm('你確定所選?')"></td></tr>
</table>
</form>
</div>
</div>
</body>
</html>