代码如下 其他都正确 就是进入不到 onClick="deleteItem() onClick="modifyItem() onClick="addItem()<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript">
function addItem() {
window.self.location = "additem.do";
}
function modifyItem() {
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;
}
if (count == 1) {
window.self.location = "item.do?command=modifyDetail;
}
}
function deleteItem() {
var flag = false;
for (var i = 0; i < document.getElementsByName("selectFlag").length; i++) {
if (document.getElementsByName("selectFlag")[i].checked) {
flag = true;
}
}
if (!flag) {
alert("请选择需要删除的物料!");
return;
}
if (window.confirm("确认删除吗?")) {
with (document.getElementById("itemForm")) {
method = "post";
action = "item.do?command=del";
submit();
}
}
}
</script>
</head>
<body>
<h3>后台酒水管理系统</h3>
<table border="1"> <c:forEach items="${list}" var="item">
<tr>
<td width="35"><input type="checkbox" name="selectFlag" id="selectFlag" class="checkbox1" value="${item.itemNo }"></td>
<td width="222">${ item.itemName }</td>
<td width="195">${ item.spec }</td>
<td width="293">${ item.pattern }</td>
<td width="293">${ item.category}</td>
</tr>
</c:forEach>
</table>
<table width="95%" height="30" border="0" align="center" >
<tr>
<td width="64%">
<input name="btnAdd" type="button" value="增加" id="btnAdd" onClick="addItem()">
<input name="btnDelete" type="button" value="删除" id="btnDelete" onClick="deleteItem()">
<input name="btnModify" type="button" value="修改" id="btnModify" onClick="modifyItem()">
</td>
</tr>
</table>
</html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript">
function addItem() {
window.self.location = "additem.do";
}
function modifyItem() {
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;
}
if (count == 1) {
window.self.location = "item.do?command=modifyDetail;
}
}
function deleteItem() {
var flag = false;
for (var i = 0; i < document.getElementsByName("selectFlag").length; i++) {
if (document.getElementsByName("selectFlag")[i].checked) {
flag = true;
}
}
if (!flag) {
alert("请选择需要删除的物料!");
return;
}
if (window.confirm("确认删除吗?")) {
with (document.getElementById("itemForm")) {
method = "post";
action = "item.do?command=del";
submit();
}
}
}
</script>
</head>
<body>
<h3>后台酒水管理系统</h3>
<table border="1"> <c:forEach items="${list}" var="item">
<tr>
<td width="35"><input type="checkbox" name="selectFlag" id="selectFlag" class="checkbox1" value="${item.itemNo }"></td>
<td width="222">${ item.itemName }</td>
<td width="195">${ item.spec }</td>
<td width="293">${ item.pattern }</td>
<td width="293">${ item.category}</td>
</tr>
</c:forEach>
</table>
<table width="95%" height="30" border="0" align="center" >
<tr>
<td width="64%">
<input name="btnAdd" type="button" value="增加" id="btnAdd" onClick="addItem()">
<input name="btnDelete" type="button" value="删除" id="btnDelete" onClick="deleteItem()">
<input name="btnModify" type="button" value="修改" id="btnModify" onClick="modifyItem()">
</td>
</tr>
</table>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货