js 全选 反选 导出全部

   1.          <ul>

                <li class="endLi" style="width:10%"><input type="button" class="formButton" value="全选" οnclick="selectAll()"/></li>

                <li class="endLi" style="width:10%"><input type="button" class="formButton" value="反选" οnclick="unselectAll()"/></li>
                <li class="endLi" style="width:10%"><input type="button" class="formButton" value="全部导出" οnclick="exportAll()"/></li>
                <li class="endLi" style="width:60%"></li>

                </ul>

2.<input type="checkbox"  name="ids" value="${user.id}" />

3.//全选方法
 function selectAll(){

    var ids=document.getElementsByName("ids");
    
    for(i=0;i<ids.length;i++){
    
        ids[i].checked=true;
    
    }

}

4.//反选方法
function unselectAll(){

    var checks=document.getElementsByName("ids");

    for(var i=0;i<checks.length;i++){
        if(checks[i].checked==true){
            checks[i].checked=false;
        }else{
            checks[i].checked=true;
        }    

    }

}

5.   //导出全部

function exportAll(){
        if(window.confirm("数据量可能比较大, 请稍等!\n点击确定开始导出。") == true){
            javascript:window.location.href='user.action';
        }else{
            return false;
        }
   
    }




猜你喜欢

转载自blog.csdn.net/wnn654321/article/details/11563251