posts - 20,comments - 6,trackbacks - 0
<html>
<head>
    
<script type="text/javascript">    
    
        
function modifyUser() {
        
var count = 0;
        
var j = 0
        
for(var i=0; i<document.getElementsByName("selectFlag").length; i++{
            
if(document.getElementsByName("selectFlag")[i].checked) {
                j 
= i;
                count
++;
            }

        }

        
if(count==0{
            alert(
"请选择需要修改的用户");
            
return;
        }

        
if(count > 1{
            alert(
"一次只能修改一个用户");
            
return;
        }

        
        
//window.self.location = "user_modify.jsp?userId=" + document.getElementsByName("selectFlag")[j].value ;
    }

    
    
function deleteUser() {
        
var flag = false;
        
for(var i=0; i<document.getElementsByName("selectFlag").length; i++{
            
if(document.getElementsByName("selectFlag")[i].checked) {
                flag 
= true;
                
break;
            }

        }

        
if(!flag) {
            alert(
"请选择需要删除的用户");
            
return;
        }

        
if(window.confirm("确认删除吗?")) {
            alert(
"删除");
            
//with(document.getElementById("userform")) {
                //method = "post";
                //action = "user_maint.jsp?command=delete";
                //submit();
            //}
        }

    }

        
    
function checkAll() {
        
for(var i=0; i<document.getElementsByName("selectFlag").length; i++{
            document.getElementsByName(
"selectFlag")[i].checked = document.getElementById("ifAll").checked
        }

    }

    
</script>
</head>
<body>
    
    
<table width="95%" border="1" cellspacing="0" cellpadding="0"    align="center">
                
<tr>
                    
<td width="55">
                        
<input type="checkbox" name="ifAll" id="ifAll" onClick="javascript:checkAll()">
                    
</td>
                    
<td>
                        用户代码
                    
</td>

                
</tr>

                
<tr>
                    
<td>
                        
<input type="checkbox" name="selectFlag" value="1">
                    
</td>
                    
<td>
                        1
                    
</td>
                
</tr>
                
                
                
<tr>
                    
<td>
                        
<input type="checkbox" name="selectFlag" value="2">
                    
</td>
                    
<td>
                        2
                    
</td>
                
</tr>
            
</table>
        
<hr color="green">
            
<table width="95%" height="30" border="0" align="center" cellpadding="0" cellspacing="0">
                
<tr>
                        
<td nowrap>
                        
<div align="right">
                            
<input name="btnAdd" type="button" id="btnAdd" value="添加" onClick="addUser()">
                            
<input name="btnDelete" type="button"    id="btnDelete" value="删除" onClick="deleteUser()">
                            
<input name="btnModify" type="button"    id="btnModify" value="修改" onClick="modifyUser()">
                        
</div>
                    
</td>
                
</tr>
            
</table>
</body>
</html>

全选,删除,修改的判断
posted on 2009-03-04 16:19 Johnhe 阅读(399) 评论(0)  编辑  收藏 所属分类: javascript

只有注册用户登录后才能发表评论。


网站导航: