Jsp+js Instance Bulk Delete data

Source: Internet
Author: User
Tags spl

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) "/>
&nbsp;
<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>

Related Article

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.