javascript常用方法7

//------------------------------- 修改数据时的判断是否有选择,是否多选 -------------------------------
function checkEditBox(objid,msg1,msg2){
var form=$(objid),eles = form.elements;
var curChekbox="";
if (eles.length > 0)
{
   var checkedboxNum=0; //选中的复选筐
   for (var i=0; i<eles.length; i++) {
      //alert(eles[i].clientTop);
  var node = eles[i];
   if (node.type == "checkbox" && node.disabled == false){
if(node.checked) checkedboxNum++;
curChekbox=node.name;
   }

    }
    if(curChekbox=='checkbox22' && checkedboxNum==1){
document.getElementById("jsmsg").innerHTML=msg2;
return false;
}
    if(checkedboxNum>1){
    //alert(msg1);
    document.getElementById("jsmsg").innerHTML=msg1;
    return;
    } else if(checkedboxNum==0){
    //alert(msg2);
    document.getElementById("jsmsg").innerHTML=msg2;
    return;
    }else {
if(checkedboxNum!=0){
   return true;
}
    }
}

}

//----------------------------------- 判断多行选择 -----------------------------------------
function checkChkBox_Multi(objid,msg1){
var form=$(objid),eles = form.elements;
var curChekbox="";
if (eles.length > 0)
{
var checkedboxNum=0; //选中的复选筐
for (var i=0; i<eles.length; i++){
//alert(eles[i].clientTop);
var node = eles[i];
if (node.type == "checkbox" && node.disabled == false)
{
if(node.checked) checkedboxNum++;
curChekbox=node.name;
}
}
if(curChekbox=='checkbox22' && checkedboxNum==1){
document.getElementById("jsmsg").innerHTML=msg1;
return false;
}
    if(checkedboxNum>1){
//alert(msg1);
document.getElementById("jsmsg").innerHTML=msg1;
return;
}else{
  return true;
}
}
}
//----------------------------------- 判断是否有选择 -----------------------------------------
function hasCheckChkBox(objid,msg1){
var form=$(objid),eles = form.elements;
var curChekbox="";
if (eles.length > 0)
{
var checkedboxNum=0; //选中的复选筐
for (var i=0; i<eles.length; i++){
    var node = eles[i];
    if (node.type == "checkbox" && node.disabled == false){
if(node.checked) checkedboxNum++;
curChekbox=node.name;
    }
}//for
if(curChekbox=='checkbox22' && checkedboxNum==1){
document.getElementById("jsmsg").innerHTML=msg1;
return false;
}
   if(checkedboxNum==0){
  
             //alert(msg1);
             document.getElementById("jsmsg").innerHTML=msg1;
             return;
}else{
  return true;
}
   
}

}

你可能感兴趣的:(JavaScript)