啊哦,代码没补全
补上原先调用的代码
<div id="forbid" style="position: absolute; visibility: hidden; z-index: 0; top: 0px; left: 0px; filter:Alpha(Opacity=60,style=0);"></div>
<a href="javascript:showLogin();showForbid();void(0);">点击选择</a>
<div id="login">
<span>请选择</span>
<div id="panel" align="left">
<%for i=1 to rs1.recordcount%>
<input type="checkbox" name="p_nowindustry" value="<%= rs1("info_id") %>"><%= rs1("thirdsort_cn") %><br>
<%rs1.movenext
next
rs1.movefirst%></div>
<div style="z-index:auto"><a href="javascript:login.style.display = 'none';forbid.style.visibility = 'hidden'; void(0);">关闭</a></div>
补上原先调用的代码
<div id="forbid" style="position: absolute; visibility: hidden; z-index: 0; top: 0px; left: 0px; filter:Alpha(Opacity=60,style=0);"></div>
<a href="javascript:showLogin();showForbid();void(0);">点击选择</a>
<div id="login">
<span>请选择</span>
<div id="panel" align="left">
<%for i=1 to rs1.recordcount%>
<input type="checkbox" name="p_nowindustry" value="<%= rs1("info_id") %>"><%= rs1("thirdsort_cn") %><br>
<%rs1.movenext
next
rs1.movefirst%></div>
<div style="z-index:auto"><a href="javascript:login.style.display = 'none';forbid.style.visibility = 'hidden'; void(0);">关闭</a></div>
点击n次还是n个点击
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body><style type="text/css">.login{
position: relative;
display: none;
top: 20px;
left: 30px;
width: 280px;
height: 150px;
background-color: #ffffff;
text-align: center;
border: solid 1px;
padding: 10px;
z-index: 100;
}
#panel{
background-color: #CCFFFF;
padding: 10px;
margin: 10px;
}
</style>
<script type="text/javascript">
function showLogin(id)
{
id.style.display = "block";
}
function showForbid()
{
forbid.style.width = document.body.clientWidth;
forbid.style.height = document.body.clientHeight;
forbid.style.visibility = "visible";
}
</script>
<div id="forbid" style="position: absolute; visibility: hidden; z-index: 0; top: 0px; left: 0px; filter:Alpha(Opacity=60,style=0);"></div><a href="javascript:showLogin(login);showForbid();void(0);">点击选择</a>
<a href="javascript:showLogin(login2);showForbid();void(0);">点击选择</a><div id="login" class="login">
<span>请选择</span>
<div id="panel" align="left"><input type="checkbox" name="p_1" value="1">1111<br></div>
<div style="z-index:auto"><a href="javascript:login.style.display = 'none';forbid.style.visibility = 'hidden'; void(0);">关闭</a></div>
</div>
<div id="login2" class="login">
<span>请选择</span>
<div id="panel" align="left"><input type="checkbox" name="p_1" value="1">2222<br></div>
<div style="z-index:auto"><a href="javascript:login2.style.display = 'none';forbid.style.visibility = 'hidden'; void(0);">关闭</a></div>
</div></body>
</html>
也就是在调用方法的时候,不在固定某个对象,而是传递当前的对象或者目标对象(或id)作为参数。
var old_login=null;//定义变量记录上一次显示的对象
var old_show=null;
function showLogin(o)
{
if(old_login){
old_login.style.display="none";
}
old_login=o;
o.style.display = "block";
}
function showForbid(o)
{
if(old_show){
old_show.style.display="none";
}
old_show=o;
o.style.width = document.body.clientWidth;
o.height = document.body.clientHeight;
o.style.visibility = "visible";
}