<script type="text/javascript">
function selectAll(field){
//根据checkbox框的名称,查询得到所有的checkbox对象
var idCheckboxs = document.getElementsByName("id");
for(var i=0; i<idCheckboxs.length; i++){
//判断顶上那个checkbox框的选中状态
if(field.checked){
idCheckboxs[i].checked = true;
}else{
idCheckboxs[i].checked = false;
}
}
}
function del(){
//判断有哪些checkbox框被选中了
var idCheckboxs = document.getElementsByName("id");
var url = "DelArticlesServlet";
var checkedIds = [];
for(var i=0; i<idCheckboxs.length; i++){
if(idCheckboxs[i].checked){
checkedIds[checkedIds.length] = idCheckboxs[i].value;
}
}
for(var i=0; i<checkedIds.length; i++){
if(i == 0){
url = url + "?id="+checkedIds[i];
}else{
url = url + "&id="+checkedIds[i];
}
}
alert(url);
//通过GET方式,向后台递交一个请求
window.location = url;
}
</script>