To achieve such a basic requirement, the page has a lot of data, you can delete one or more, before the deletion of the judge whether to select at least one, otherwise prompted.
Copy Code code as follows:
function DeleteUser () {
I was trying to save the content in a str+= "" way, but no.
var str;
var array = new Array (); The ID used to save the selected piece of data
VAR flag; Determine whether an option is not selected
$ ("Input[name= ' Selectflag ']:checkbox"). each (function () {//Traverse all checkbox with Name Selectflag
if ($ (this). attr ("checked")) {//Determine if selected
Flag = true; As long as there is one selected set to True
}
})
if (flag) {
$ ("Input[name= ' Selectflag ']:checkbox"). each (function () {//Traverse all checkbox with Name Selectflag
if ($ (this). attr ("checked")) {//Determine if selected
Alert ($ (this). Val ());
Array.push ($ (this). Val ()); Add the selected value to the array
str+=$ (This). Val () + ",";
}
})
Data that will be deleted collectively is passed to action
Window.self.location = "deleteuser?info=" + array;
} else {
Alert ("Please select at least one user");
}
}
Background action to receive data for deletion
Copy Code code as follows:
@Override
Public String execute () throws Exception {
//TODO auto- Generated method stub
//foreground is the first decomposition string transmitted in A,B,C format
string s[] = Info.split (",");
/*
* for (int i=0;i<s.length;i++) {System.out.println (s[i]);}
/
if (s.length > 0) {
for (int i = 0; i < s.length; i++) {
Userdao.deleteuser (s[i));
}
Return "Success";
}