上怎么通过checkbox来实现删除多条记录
1个回答
展开全部
//1.如果checkbox name一样
var boxValue = "";
var box = document.getElementsByName("checkBoxName");//checkbox的name
for(var i = 0 ; i < box.length ; i ++){
if(box[i].checked){
boxValue += "'"+box[i].value+"',";
}
}
if(boxValue.length>1){
boxValue = boxValue.substring(0,boxValue.length-1);
}
//2.通过input获取,但是页面没有其他类型的checkbox
var inputRef = document.getElementsByTagName("input");
var len = inputRef.length;
var arsInput = "";
var boxValue = "";
for(var i = 0; i < len; i++){
arsInput = inputRef[i];
if(arsInput.type=="checkbox" ){
if(arsInput.checked){
boxValue += "'"+arsInput[i].value+"',";
}
}
}
if(boxValue.length>1){
boxValue = boxValue.substring(0,boxValue.length-1);
}
var boxValue = "";
var box = document.getElementsByName("checkBoxName");//checkbox的name
for(var i = 0 ; i < box.length ; i ++){
if(box[i].checked){
boxValue += "'"+box[i].value+"',";
}
}
if(boxValue.length>1){
boxValue = boxValue.substring(0,boxValue.length-1);
}
//2.通过input获取,但是页面没有其他类型的checkbox
var inputRef = document.getElementsByTagName("input");
var len = inputRef.length;
var arsInput = "";
var boxValue = "";
for(var i = 0; i < len; i++){
arsInput = inputRef[i];
if(arsInput.type=="checkbox" ){
if(arsInput.checked){
boxValue += "'"+arsInput[i].value+"',";
}
}
}
if(boxValue.length>1){
boxValue = boxValue.substring(0,boxValue.length-1);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询