Javascript 继续显示一个div标签,直到所有复选框都像gmail一样取消标记
我的问题是,我想先隐藏我的删除按钮,就像用户在复选框上标记一样 删除按钮会一直显示,直到所有复选框都未取消标记为止 这就是我试图做到这一点的方式,当我取消标记一个复选框时,我面临的问题我的删除按钮消失了,尽管我的复选框的其余部分被标记了Javascript 继续显示一个div标签,直到所有复选框都像gmail一样取消标记,javascript,Javascript,我的问题是,我想先隐藏我的删除按钮,就像用户在复选框上标记一样 删除按钮会一直显示,直到所有复选框都未取消标记为止 这就是我试图做到这一点的方式,当我取消标记一个复选框时,我面临的问题我的删除按钮消失了,尽管我的复选框的其余部分被标记了 <%@page import="java.util.List"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncodin
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@page
import="com.nousinfo.tutorial.employee.service.model.bo.EmployeeBO"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<link rel="stylesheet" href="css/style.css" type="text/css"></link>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Home</title>
<script type="text/javascript">
function windowLoadByName(windowHeight, windowWidth) {
var centerWidth = (window.screen.width - windowWidth) / 2;
var centerHeight = (window.screen.height - windowHeight) / 2;
newWindow = window.open(
'PopUp.jsp',
'mywindow',
'resizable=0,width=' + windowWidth + ',height=' + windowHeight
+ ',left=' + centerWidth + ',top=' + centerHeight,
"status=1").divHiding(1);
newWindow.focus();
}
function windowLoadById(windowHeight, windowWidth) {
var centerWidth = (window.screen.width - windowWidth) / 2;
var centerHeight = (window.screen.height - windowHeight) / 2;
newWindow = window.open(
'PopUp.jsp',
'mywindow',
'resizable=0,width=' + windowWidth + ',height=' + windowHeight
+ ',left=' + centerWidth + ',top=' + centerHeight)
.divHiding(2);
newWindow.focus();
return newWindow.name;
}
function loadName(name) {
this.firstName = name;
window.location = 'http://localhost:8080/EmployeeWeb/GetEmployee?key1='
+ encodeURIComponent(firstName);
}
function loadId(id) {
this.id = id;
window.location = 'http://localhost:8080/EmployeeWeb/GetEmployee?key2='
+ encodeURIComponent(id);
}
function showMe (it, box) {
var vis = (box.checked) ? "block" : "none";
document.getElementById(it).style.display = vis;
}
</script>
</head>
<body background="transparent">
<table width="951" height="116" border="0" align="center">
<tr>
<td width="661" height="112" bgcolor="#D1D1FF"><font size="6">EmployeeManagement</font>
</td>
<td width="266" height="112" align="center" bgcolor="#FFFFFF"><img
src="image/nous.jpg" alt="1" width="266" height="84" /></td>
</tr>
</table>
<p> </p>
<table width="949" height="183" border="0" align="center">
<tr>
<td height="42" align="center" bgcolor="#3366FF"><strong>Find
Employee </strong></td>
</tr>
<tr>
<td width="943" height="43"><input id="findid" name="button"
type="submit" value="Find_Employee_By_ID"
onClick="windowLoadById(250,500)" /></td>
</tr>
<tr>
<td height="43"><input id="findname" name="submit2"
type="button" value="Find_Employee_By_Name"
onClick="windowLoadByName(250,500)" /></td>
</tr>
<tr>
<td><form id="form2" action="GetEmployee">
<input type="submit" name="submit3" value="Get_All_Employee" />
</form></td>
</tr>
<tr>
<td><form id="form2" action="CreateEmployee.jsp">
<input type="submit" name="create" value="CreateEmployee" />
</form></td>
</tr>
</table>
<p> </p>
<br>
<br>
<div id="div12">
<form action="UpdateEmployeeServlet">
<table width="725" border="1" align="center" cellpadding="5"
cellspacing="5">
<tr>
<th width="118">check</th>
<th width="118">EmployeeNumber</th>
<th width="118">First Name</th>
<th width="118">Last Name</th>
<th width="118">Title</th>
<th width="118">Address1</th>
<th width="118">Address2</th>
<th width="118">City</th>
<th width="118">Detail
<th>
</tr>
<c:forEach var="employeeBO" items="${listemployeeBo}">
<tr>
<td><input type="checkbox" value='${employeeBO.empNumber}'
name="checked" onclick="showMe('div1',this)"></td>
<td>${employeeBO.empNumber}</td>
<td>${employeeBO.firstName}</td>
<td>${employeeBO.lastName}</td>
<td>${employeeBO.title}</td>
<td>${employeeBO.address1}</td>
<td>${employeeBO.address2}</td>
<td>${employeeBO.city}</td>
<td><a href="javascript:loadId(${employeeBO.empNumber})">Details</a></td>
</tr>
</c:forEach>
</table>
<div id="div1" style="display:none;">
<table>
<tr>
<td><input type="hidden" name="updateStatusDelete" value="D" />
<input type="submit" name="delete" value="Delete" /></td>
</tr>
</table>
</div>
</form>
</div>
</body>
</html>
家
函数windowLoadByName(窗口高度、窗口宽度){
var centerWidth=(window.screen.width-windowWidth)/2;
var centerHeight=(window.screen.height-windowHeight)/2;
newWindow=window.open(
'PopUp.jsp',
“我的窗口”,
'可调整大小=0,宽度='+窗口宽度+',高度='+窗口高度
+'左='+中心宽度+',顶='+中心高度,
“状态=1”)。第(1)款;
newWindow.focus();
}
函数windowLoadById(窗口高度、窗口宽度){
var centerWidth=(window.screen.width-windowWidth)/2;
var centerHeight=(window.screen.height-windowHeight)/2;
newWindow=window.open(
'PopUp.jsp',
“我的窗口”,
'可调整大小=0,宽度='+窗口宽度+',高度='+窗口高度
+'左='+中心宽度+',顶='+中心高度)
.2(2);
newWindow.focus();
返回newWindow.name;
}
函数loadName(名称){
this.firstName=名称;
window.location=http://localhost:8080/EmployeeWeb/GetEmployee?key1='
+编码元件(名字);
}
函数loadId(id){
this.id=id;
window.location=http://localhost:8080/EmployeeWeb/GetEmployee?key2='
+编码元件(id);
}
函数showMe(it,box){
var vis=(复选框)?“块”:“无”;
document.getElementById(it.style.display=vis);
}
员工管理
查找
员工
检查
雇员人数
名字
姓
标题
地址1
地址2
城市
细节
${employeeBO.empNumber}
${employeeBO.firstName}
${employeeBO.lastName}
${employeeBO.title}
${employeeBO.address1}
${employeeBO.address2}
${employeeBO.city}
用以下内容替换您的showMe
功能:
// box is not needed now, it checks all checkboxes to see
// if any one of them is checked
function showMe(it, box) {
var hasChecked = false;
var chks = document.getElementsByName('checked');
var vis = '';
for ( var i = 0; i < chks.length; i++ ) {
if ( chks[ i ].checked ) {
hasChecked = true;
break;
}
}
if ( hasChecked == false ) {
vis = "none";
} else {
vis = "block";
}
document.getElementById( it ).style.display = vis;
}
//现在不需要复选框,它会选中所有复选框以查看
//如果检查其中任何一个
函数showMe(it、box){
var hasChecked=false;
var chks=document.getElementsByName('checked');
var-vis='';
对于(变量i=0;i
希望有帮助。如果你不介意(chks[i].checked){hasChecked=true;break;}当然可以,你能解释一下这句话吗。它检查复选框是否已选中。如果选择了它,它会将变量
hasChecked
标记为true
,并中断循环,因为我们已经找到了一个选中的,因此不需要再检查任何复选框。