function deleteAllBook(){
// 获取input标签下type类型为checkbox的所有选中的checked框
var option = $("input:checkbox:checked");
//取出checked框中的值
var checkedId = "";
var boo=true;
for (var i = 0, len = option.length; i < len; i++) {
if (boo) {
boo=false;
checkedId += option[i].value;
}
else
checkedId += ","+option[i].value;
}
var flag = window.confirm("你确定要删除这条记录吗");
//alert(checkedId);
if(flag){
window.location.href = "deleteSomeBookServlet?bno="+checkedId;
}
}
checkedld中就存放这你选择的复选框中的id值,并以逗号分隔,例如:2,5,9
接上例:如果是2,5,9,分割后会变成{2,5,9}
boolean flag=false;
public boolean deleteSomeBook(String array) {
conn=getConnectionn();
try {
pStat =conn.prepareStatement("delete from t_book where bno = ?");
pStat.setString(1, array);
int cnt=pStat.executeUpdate();
if( cnt>0 ) return true;
else return false;
}catch (Exception e) { return false; }
finally{ close(); }
}