Jsp+js Instance Bulk Delete data
The JSP gets the data into the data and then generates the legitimate SQL statement
String Action =request.getparameter ("action");
String[] name=request.getparametervalues ("box");
String deng= "";
String spl= ",";
if (action = null)
{
Action= "my";
}
if (Action.equals ("DeleteAll") && name!= null)
{
int length = name.length-1;
for (int i=0;i<=length;i++)
{
if (i = length)
{
Deng = Deng+name[i];
}else{
Deng = DENG+NAME[I]+SPL;
}
}
Statement stmt_dxh=conn.createstatement ();
String sql= "Delete from Hl_jobbook where ID" ("+deng+");
int den=stmt_dxh.executeupdate (SQL);
if (den>0) {
Out.print ("<script type=" Text/javascript "> Alert
("Bulk deletion was deleted successfully!") "); window.location.href= ' manage_jobbook.jsp ';
</script> ");
}
Stmt_dxh.close ();
}
Here is the JS full selection code
<script language= "JavaScript" >
function B (obj)
{
var m = document.getelementsbyname (' box ');
var btn = Myform.btn.value;
var L = m.length;
for (var i=0; i< l; i++)
{
m[i].checked = = True
? M[i].checked = False
: m[i].checked = true;
}
if (btn = = ' All selected ')
{
Myform.btn.value = ' anti-election ';
}
Else
{
Myform.btn.value = ' all election ';
}
}
</script>
HTML code
<form action= "? Action=deleteall" method= "post" name= "MyForm" >
<input name= "box" type= "checkbox" class= "Input_focus" value= "<%"
=rs3.getstring ("id")%> "/>
<input type= "button" Name= "btn" size= "value=" all Select "onclick=" b
(this.value) "/>
<label>
<input type= "Submit" name= "submit" value= "Delete selected CV"
onclick= "return confirm (' Confirm deletion of the selected CV, can not be recovered after deletion ');"/>
</label>
</form>