87,901
社区成员
发帖
与我相关
我的任务
分享
function del(path,obj) {
if(confirm("要删除吗?")){
var n = 0;
for (var i = 0; i < document.all(obj).length; i++) {
var e = selectForm.elements[i];
if (e.checked == true) {
++n;
}
}
if (n == 0) {
alert("您还没有选择要删除选项!");
return false;
} else {
var id = "";
for (var i = 0; i < document.all(obj).length; i++) {
var e = selectForm.elements[i];
if (e.checked == true) {
id += e.value+",";
}
}
document.location.href = path+id;
}
}
}
$(function() {
$("#abv").click(function() {
var aa = document.getElementsByName("chkb");
var ss = "";
for (var i = 0; i < aa.length; i++) {
if (aa[i].checked) {
ss += aa[i].value;
}
}
if (ss == "") {
alert("您还没有选择要删除的按钮!");
} else {
if (confirm("要删除吗?")) {
var ar = new Array();
$(":checkbox:checked").each(function() {
ar.push($(this).val());
});
$("#div1").html("您删除的多选按钮值为:" + ar)
}
}
});
})
$(function() {
$("#abv").click(function() {
var aa = document.getElementsByName("chkb");
var ss = "";
for (var i = 0; i < aa.length; i++) {
aa[i].checked = true;
ss += aa[i].value;
}
if (ss == "") {
alert("您还没有选择要删除的按钮!");
} else {
if (confirm("要删除吗?")) {
var ar = new Array();
$(":checkbox:checked").each(function() {
ar.push($(this).val());
});
$("#div1").html("您删除的多选按钮值为:" + ar)
}
}
});
})
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#abv").click(function(){
if($(":checkbox:checked").length==0){
alert("您还没有选择要删除的按钮!");
}else{
if(confirm("要删除吗?")){
var ar=new Array();
$(":checkbox:checked").each(function(){
ar.push($(this).val());
});
$("#div1").html("您删除的多选按钮值为:"+ar)
}
}
});
})
</script>
<input type="button" id="abv" value="删除按钮"/>
<input type="checkbox" id="checkbox1" value="1"/>
<input type="checkbox" id="checkbox2" value="2"/>
<input type="checkbox" id="checkbox3" value="3"/>
<input type="checkbox" id="checkbox4" value="4"/>
<div id="div1">
<div>
<input type="checkbox" name="id" value="1">
<input type="checkbox" name="id" value="2">
<input type="checkbox" name="id" value="3">
<input type="checkbox" name="id" value="4">
<input type="button" onclick="del('#url?id=','id')" value="删除">
<script type="text/javascript">
function del(path,obj) {
if(confirm("要删除吗?")){
var id=document.getElementsByName(obj),n="";
for(var i=0;i<id.length;i++){
if(id[i].checked)n+=id[i].value+",";
}
if(""==n){
alert("您还没有选择要删除选项!");
}else{
document.location.href = path+n;
}
}
}
</script>