不知道还有没有人在啊 我又有问题了
<%
bm_id=request( "bm_id ")
%>
<% set rsdan=server.createobject( "adodb.recordset ")
sql= "select BM_Person.*,bm_yuangong.Person_xingming from BM_Person,bm_yuangong where BM_Person.person_id=bm_yuangong.person_id and bm_id in ( "&BM_id& ") "
rsdan.open sql,conn,3,1
if rsdan.eof then
set rscyc=server.createobject( "adodb.recordset ")
sql= "delete from BM where BM_id in ( "&BM_id& ") "
rscyc.open sql,conn,3,1
response.redirect "Departmentmanage.asp "
else
tmp= " "
for i=0 to rsdan.recordcount-1
tmp= tmp & rsdan( "Person_xingming ") & ", "
rsdan.movenext
next
%>
<script language= "JavaScript ">
alert( "此部门里存在员工 ' <%=tmp%> '不能删除!\n清除部门里的人员进行此操作! ");
history.go(-1);
</script>
<%
end if
%>
这段代码的js 怎么 在列表页 提示阿
现在的效果是 弹出提示的时候 页面上是一片空白,如何处理比较好 谢谢
[解决办法]
一下代码看看
<%
Dim bolFlag
bm_id=request( "bm_id ")
set rsdan=server.createobject( "adodb.recordset ")
sql= "select BM_Person.*,bm_yuangong.Person_xingming from BM_Person,bm_yuangong where BM_Person.person_id=bm_yuangong.person_id and bm_id in ( "&BM_id& ") "
rsdan.open sql,conn,3,1
if rsdan.eof then
set rscyc=server.createobject( "adodb.recordset ")
sql= "delete from BM where BM_id in ( "&BM_id& ") "
rscyc.open sql,conn,3,1
response.redirect "Departmentmanage.asp "
else
tmp= " "
for i=0 to rsdan.recordcount-1
tmp= tmp & rsdan( "Person_xingming ") & ", "
rsdan.movenext
next
bolFlag = 1
end if
If bolFlag = 1 Then
%>
<script language= "JavaScript ">
alert( "此部门里存在员工 ' <%=tmp%> '不能删除!\n清除部门里的人员进行此操作! ");
history.go(-1);
</script>
<%
End if
%>
[解决办法]
我觉得xie_yanke(谢烟客)说的有道理,在显示部门列表的时候,作如下判断:如果部门下面有人员的话,就把checkbox设成不能用,即 <input type= "checkbox " name= "BM_id " value= " <%=rscyc( "BM_id ")%> " disabled> ,如果部门下面没有人员才允许选择进行删除
[解决办法]
修改成如下形式,你自己加到代码中
<script language= "JavaScript " type= "text/javascript ">
<!--
function del_cyc()
{
var sForm = document.xoYuStudioH;
var num = 0;
if(typeof(sForm.BM_id.length)== "undefined ")
{
if (sForm.BM_id.checked==false)
{
alert( '请至少选择一个部门! ');
return false;
}
else
{
document.xoYuStudioH.action= "DepartmentDel.asp ";
document.xoYuStudioH.submit();
return true;
}
}
else
{
for(var i=0;i <=sForm.BM_id.length-1;i++)
{
(sForm.BM_id(i).checked)?num+=1: ' '
}
if(num== '0 ')
{
alert( '请至少选择一个部门! ');
return false;
}
if(confirm( '您确定要删除所选部门吗!? '))
{
document.xoYuStudioH.action= "DepartmentDel.asp ";
document.xoYuStudioH.submit();
return true;
}
}
}
function chk(obj)
{
if (obj.checked)
{
if (obj.getAttribute( "hp ")== "1 ")
{
alert( "该部门下面有人员,不能删除 ");
obj.checked=false;
return;
}
}
}
//-->
</script>
</head>
<body>
<form name=ff action= "*.asp " method=post>
<input type= "checkbox " name= "BM_id " value= "99 " hp= "0 " onclick= "chk(this) "> 部门一(部门下面没有数据) <br>
<input type= "checkbox " name= "BM_id " value= "100 " hp= "1 " onclick= "chk(this) "> 部门二(部门下面有数据) <br>
<input type= "checkbox " name= "BM_id " value= "101 " hp= "0 " onclick= "chk(this) "> 部门三(部门下面没有数据) <br>
<input type= "checkbox " name= "BM_id " value= "102 " hp= "1 " onclick= "chk(this) "> 部门四(部门下面有数据) <br>
<input onClick= "javascript:del_cyc(); " name= "xoYuStudioDo4 " value= "删除部门 " type= "button " title= "删除选定记录 " />
</form>