Firfox与IE全选checkbox兼容问题:IE支持myform.all.tags("input");Firfox不支持。
var tags = document.myform.elements["user_id"] ;
此方法两个浏览器都兼容
function SwitchCheck(){ var checkbox=document.myform.elements["user_id"]; for (var i=0; i<checkbox.length; i++) { if(checkbox[i].type=="checkbox") { checkbox[i].checked = !checkbox[i].checked; } } }
function getCheckedValue(){ var checkedValue="0"; //var tags=myform.all.tags("input"); var tags = document.myform.elements["user_id"] ;
for (var i=0; i<tags.length; i++) { if(tags[i].type=="checkbox" && tags[i].checked==true) { checkedValue+=","+tags[i].value; } } return checkedValue //alert(checkedValue); }
function OnDel(){ var delId = getCheckedValue(); if(delId=="0"){ alert("请选择要删除的用户!"); return false; } if(confirm("确定要删除选定的用户吗?")){ //document.myform.action="user_operate.php"; document.getElementById("type").value = "del_user"; document.getElementById("userid").value = delId; //alert(document.getElementById("user_id").value); document.myform.submit(); return false; }else{ return false; } }
function OnMove(){ var moveId = getCheckedValue(); if(moveId=="0"){ alert("请选择要移动的用户!"); return false; } var move_group = document.getElementById("move_group"); if(move_group.value==''){ alert("请选择目标栏目!"); move_group.focus(); return false; } if(confirm("确定要移动选定的用户吗?")){ //document.myform.action="user_operate.php"; document.getElementById("type").value = "move_user"; document.getElementById("userid").value = moveId; //alert(document.getElementById("user_id").value); document.myform.submit(); return true; }else{ return false; } }