亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquery復(fù)選框checkbox實(shí)現(xiàn)刪除前判斷

 更新時(shí)間:2014年04月20日 15:16:11   作者:  
頁面有很多數(shù)據(jù),可以刪除一條或多條,刪除前判斷是否選中至少一條,否則提示,具體示例如下,需要的朋友可以參考下
實(shí)現(xiàn)這樣一個(gè)基本需求,頁面有很多數(shù)據(jù),可以刪除一條或多條,刪除前判斷是否選中至少一條,否則提示。
復(fù)制代碼 代碼如下:

function deleteUser() {
//當(dāng)時(shí)是想把內(nèi)容以str+=""的方式 進(jìn)行保存 ,但不行
//var str;
var array = new Array(); //用于保存 選中的那一條數(shù)據(jù)的ID
var flag; //判斷是否一個(gè)未選
$("input[name='selectFlag']:checkbox").each(function() { //遍歷所有的name為selectFlag的 checkbox
if ($(this).attr("checked")) { //判斷是否選中
flag = true; //只要有一個(gè)被選擇 設(shè)置為 true
}
})
if (flag) {
$("input[name='selectFlag']:checkbox").each(function() { //遍歷所有的name為selectFlag的 checkbox
if ($(this).attr("checked")) { //判斷是否選中
//alert($(this).val());
array.push($(this).val()); //將選中的值 添加到 array中
//str+=$(this).val()+",";
}
})
//將要集體刪除的數(shù)據(jù) 傳遞給action處理
window.self.location = "deleteUser?info=" + array;
} else {
alert("請至少選擇一個(gè)用戶");
}
}

后臺(tái)action進(jìn)行接收數(shù)據(jù) 進(jìn)行刪除
復(fù)制代碼 代碼如下:

@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
//前臺(tái)是以a,b,c格式進(jìn)行傳輸?shù)?首先分解字符串
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";
}

相關(guān)文章

最新評論