Jsp + js instances batch delete data
Jsp obtains data and stores the data, and then generates valid SQL statements.
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 in (" + deng + ")";
Int den=stmt_dxh.exe cuteUpdate (SQL );
If (den> 0 ){
Out. print ("<script type =" text/javascript "> alert
("Batch deletion has been successfully deleted! "); Window. location. href = 'Manage _ JobBook. jsp ';
</Script> ");
}
Stmt_dxh.close ();
}
Below are all js Code Selection
<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 = 'select ')
{
Myform. btn. value = 'select ';
}
Else
{
Myform. btn. value = 'select ';
}
}
</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 = "50" value = "select all" onclick = "B
(This. value) "/>
& Nbsp;
<Label>
<Input type = "submit" name = "Submit" value = "delete selected resume"
Onclick = "return confirm ('Are you sure you want to delete the selected resume? It cannot be restored after deletion ');"/>
</Label>
</Form>