jsp在每个记录里都添加一个删除按钮,点击后即删除数据库里本记录
<%inti=0;%><scripttype="text/javascript">functiondeleteFromGoods(){if(window.confirm(...
<%
int i = 0;
%>
<script type="text/javascript">
function deleteFromGoods() {
if (window.confirm("确认吗?")) {
document.getElementById("form<%=i%>").action = "<%=request.getContextPath()%>/jsp/print.jsp";
document.getElementById("form<%=i%>").submit();
}
}
function modifiedFromGoods() {
document.getElementById("form1").action = "<%=request.getContextPath()%>/jsp/goods/modifiedGoods.jsp";
document.getElementById("form1").submit();
}
</script>
<tr>
<%for(int j = 0;j < 4;j++){ %>
<form id="form<%=i++%>" method="post">
<td>
<input type="hidden" name="goodsNo" value="<%=j%>"/>
<input type="hidden" name="goodsName" value="<%=j%>" />
<input type="hidden" name="goodsUnivalent" value="<%=j%>" />
<input type="hidden" name="goodsStandard" value="<%=j%>" />
<input type="hidden" name="goodsNumber" value="<%=j%>" />
<input type="button" value="删除" onclick=deleteFromGoods() />
<input type="button" value="修改" onclick=modifiedFromGoods() />
form<%=i%>
</td>
</form>
<%} %>
</tr>
以上为测试代码。跳转到print.jsp时输出表单值,为什么无论点击哪一个删除按钮都是显示form1的信息。该怎么修改才能正确呢?
大神快帮帮我吧。。。 展开
int i = 0;
%>
<script type="text/javascript">
function deleteFromGoods() {
if (window.confirm("确认吗?")) {
document.getElementById("form<%=i%>").action = "<%=request.getContextPath()%>/jsp/print.jsp";
document.getElementById("form<%=i%>").submit();
}
}
function modifiedFromGoods() {
document.getElementById("form1").action = "<%=request.getContextPath()%>/jsp/goods/modifiedGoods.jsp";
document.getElementById("form1").submit();
}
</script>
<tr>
<%for(int j = 0;j < 4;j++){ %>
<form id="form<%=i++%>" method="post">
<td>
<input type="hidden" name="goodsNo" value="<%=j%>"/>
<input type="hidden" name="goodsName" value="<%=j%>" />
<input type="hidden" name="goodsUnivalent" value="<%=j%>" />
<input type="hidden" name="goodsStandard" value="<%=j%>" />
<input type="hidden" name="goodsNumber" value="<%=j%>" />
<input type="button" value="删除" onclick=deleteFromGoods() />
<input type="button" value="修改" onclick=modifiedFromGoods() />
form<%=i%>
</td>
</form>
<%} %>
</tr>
以上为测试代码。跳转到print.jsp时输出表单值,为什么无论点击哪一个删除按钮都是显示form1的信息。该怎么修改才能正确呢?
大神快帮帮我吧。。。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询