Jsp + js instances batch delete data

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.