function deleteAll() {
var all = document.getElementsByName( "checkname");//Get the content you selected is an array
if (all == null || all.length == 1) {
alert("No order yet");
return ;
} else {
var idStr = "";//Define a string of id you want to delete
for ( var i = 0; i < all.length; i ) {
if (all[i].checked) {
idStr = all[i].value ",";//Connect the ids separated by commas
}
}
var result = confirm("Select to delete");
if (result) {
window.location.href = "deleteOrderAction?action=deleteAll&idStr="
idStr;
} else {
return null;
}
}
}
Finally perform business processing
String[] arr = idStr.split(",");//Will get the id string array and use comma split to get each one id
for (String str : arr) {
int orderid = Integer.parseInt(str);
OrderService.deleteOrder(orderid);
}
Summary: The operation of all deletion and clearing is the process of concatenating and splitting strings.