JS全选全不选取值

阅读更多
function selectAll(flag){
  var ids = document.getElementsByName("ids");
  for(var i=0;i     var obj = ids[i];
    obj.checked = flag;
  }
}
function selectCount(){
   var count = 0;
   var ids = document.getElementsByName("ids");
  for(var i=0;i     var obj = ids[i];
    if(obj.checked){
       count++;
    }
  }
  return count;
}

function getSelectValue(){
   var ids = document.getElementsByName("ids");
   var idsValue="";
  for(var i=0;i     var obj = ids[i];
    if(obj.checked){
       //return obj.value;
idsValue += obj.value+",";
    }
  }
 
  return idsValue;
}  
function sendAll(){
 
  if(selectCount()<1){
     alert("至少要选中一个选项!!");
     return ;
  }
  var url = "sendMessageInfo.jsp?ids="+getSelectValue();
  alert(url);
 
}

你可能感兴趣的:(全选,全不选取值)