jsp confirm点击取消了还是继续删除操作

qq_39096494 2017-06-08 05:53:45
如题,代码如下,点击取消仍然会删除数据,求助各路大神


<%@page pageEncoding="utf-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title-Here</title>
<link type="text/css" rel="stylesheet" media="all" href="styles/global.css" />
<link type="text/css" rel="stylesheet" media="all" href="styles/global_color.css" />
<script language="javascript" type="text/javascript">
//排序按钮的点击事件
function sort(btnObj) {
if (btnObj.className == "sort_desc")
btnObj.className = "sort_asc";
else
btnObj.className = "sort_desc";
}

//启用
function startFee() {
var r = window.confirm("确定要启吗?启用后将不能修改和删除。");
document.getElementById("operate_result_info").style.display = "block";
}
//删除
function deleteFee() {
var r = window.confirm("确定要删除吗?");
document.getElementById("operate_result_info").style.display = "block";
}
</script>
</head>
<body>
<!--Logo区域开始-->
<div id="header">
<c:import url="../logo.jsp"></c:import>
</div>
<!--Logo区域结束-->
<!--导航区域开始-->
<div id="navi">
<c:import url="../menu.jsp"></c:import>
</div>
<!--导航区域结束-->
<!--主要区域开始-->
<div id="main">
<form action="" method="">
<!--排序-->
<div class="search_add">

<div>
<span class="info">场地费用</span>
<input type="text" value="${caot.baseDuration }" class="width100" />
<span class="info">元</span>
</div>
<div>
<span class="info">本次参与人数</span>
<input type="text" value="${caot.baseDuration1 }" class="width100" />
<span class="info">人</span>
</div>

<input type="button" value="增加" class="btn_add" onclick="location.href='toAddCost.do';" />
</div>
<!--启用操作的操作提示-->
<div id="operate_result_info" class="operate_success">
<img src="images/close.png" onclick="this.parentNode.style.display='none';" />
删除成功!
</div>
<!--数据区域:用表格展示数据-->
<div id="data">
<table id="datalist">
<tr>
<th>资费ID</th>
<th class="width100">姓名</th>
<th>昵称</th>
<th>性别</th>
<th>余额</th>
<th>创建时间</th>
<th>用户名</th>
<th class="width50">状态</th>
<th class="width200">扣费计算</th>
</tr>

<c:forEach items="${costs }" var="c">


<tr>
<td>${c.user_ID }</td>
<td><a href="fee_detail.html">${c.name }</a></td>
<td>${c.nickname }</td>
<td>${c.sex }</td>
<td>${c.balance }</td>
<td>${c.time }</td>
<td>${c.user_name }</td>

<td>
<input type="button" value="启用" class="btn_start" onclick="startFee();" />
<input type="button" value="修改" class="btn_modify" onclick="location.href='toUpdateCost.do?id=${c.user_ID}';" />
<input type="button" value="删除" class="btn_delete" onclick="deleteFee();location.href='delete.do?id=${c.user_ID}';" />
</td>
</tr>


</c:forEach>

</table>
</div>
<!--分页-->
<div id="pages">
<a href="#">上一页</a>
<a href="#" class="current_page">1</a>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
<a href="#">5</a>
<a href="#">下一页</a>
</div>
</form>
</div>
<!--主要区域结束-->
</body>
</html>
...全文
509 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_39096494 2017-06-09
  • 打赏
  • 举报
回复
引用 1 楼 jslang 的回复:



<%@page pageEncoding="utf-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Title-Here</title>
        <link type="text/css" rel="stylesheet" media="all" href="styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="styles/global_color.css" />
        <script language="javascript" type="text/javascript">
            //排序按钮的点击事件
            function sort(btnObj) {
                if (btnObj.className == "sort_desc")
                    btnObj.className = "sort_asc";
                else
                    btnObj.className = "sort_desc";
            }

            //启用
            function startFee() {
                var r = window.confirm("确定要启吗?启用后将不能修改和删除。");
                document.getElementById("operate_result_info").style.display = "block";
            }
            //删除
            function deleteFee() {
                var r = window.confirm("确定要删除吗?");
                if (r)
	                document.getElementById("operate_result_info").style.display = "block";
	            return r;
            }
        </script>        
    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
        	<c:import url="../logo.jsp"></c:import>
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">   
        	<c:import url="../menu.jsp"></c:import>            
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">
            <form action="" method="">
                <!--排序-->
                <div class="search_add">
                
                    <div>
                    	<span class="info">场地费用</span>
           	<input type="text" value="${caot.baseDuration }" class="width100" />
        	<span class="info">元</span>	
                    </div>
                     <div>
                     	<span class="info">本次参与人数</span>
           	<input type="text" value="${caot.baseDuration1 }" class="width100" />
        	<span class="info">人</span>	
                    </div>
                    
                    <input type="button" value="增加" class="btn_add" onclick="location.href='toAddCost.do';" />
                </div> 
                <!--启用操作的操作提示-->
                <div id="operate_result_info" class="operate_success">
                    <img src="images/close.png" onclick="this.parentNode.style.display='none';" />
                    删除成功!
                </div>
                <!--数据区域:用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                        <tr>
                            <th>资费ID</th>
                            <th class="width100">姓名</th>
                            <th>昵称</th>
                            <th>性别</th>
                            <th>余额</th>
                            <th>创建时间</th>
                            <th>用户名</th>
                            <th class="width50">状态</th>
                            <th class="width200">扣费计算</th>
                        </tr>  
                        
                        <c:forEach items="${costs }" var="c"> 
                        
                        
                        	 <tr>
                            <td>${c.user_ID }</td>
                            <td><a href="fee_detail.html">${c.name }</a></td>
                            <td>${c.nickname }</td>
                            <td>${c.sex }</td>
                            <td>${c.balance }</td>
                            <td>${c.time }</td>
                            <td>${c.user_name }</td>
                            
                            <td>                                
                                <input type="button" value="启用" class="btn_start" onclick="startFee();" />
                                <input type="button" value="修改" class="btn_modify" onclick="location.href='toUpdateCost.do?id=${c.user_ID}';" />
                                <input type="button" value="删除" class="btn_delete" onclick="if(deleteFee()) location.href='delete.do?id=${c.user_ID}';" />
                            </td> 
                        </tr>
                     
                        
                        </c:forEach>
                        	
                    </table>
                </div>
                <!--分页-->
                <div id="pages">
        	        <a href="#">上一页</a>
                    <a href="#" class="current_page">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                    <a href="#">4</a>
                    <a href="#">5</a>
                    <a href="#">下一页</a>
                </div>
            </form>
        </div>
        <!--主要区域结束-->
    </body>
</html>
太感谢了,问题解决了
天际的海浪 2017-06-08
  • 打赏
  • 举报
回复



<%@page pageEncoding="utf-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Title-Here</title>
        <link type="text/css" rel="stylesheet" media="all" href="styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="styles/global_color.css" />
        <script language="javascript" type="text/javascript">
            //排序按钮的点击事件
            function sort(btnObj) {
                if (btnObj.className == "sort_desc")
                    btnObj.className = "sort_asc";
                else
                    btnObj.className = "sort_desc";
            }

            //启用
            function startFee() {
                var r = window.confirm("确定要启吗?启用后将不能修改和删除。");
                document.getElementById("operate_result_info").style.display = "block";
            }
            //删除
            function deleteFee() {
                var r = window.confirm("确定要删除吗?");
                if (r)
	                document.getElementById("operate_result_info").style.display = "block";
	            return r;
            }
        </script>        
    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
        	<c:import url="../logo.jsp"></c:import>
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">   
        	<c:import url="../menu.jsp"></c:import>            
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">
            <form action="" method="">
                <!--排序-->
                <div class="search_add">
                
                    <div>
                    	<span class="info">场地费用</span>
           	<input type="text" value="${caot.baseDuration }" class="width100" />
        	<span class="info">元</span>	
                    </div>
                     <div>
                     	<span class="info">本次参与人数</span>
           	<input type="text" value="${caot.baseDuration1 }" class="width100" />
        	<span class="info">人</span>	
                    </div>
                    
                    <input type="button" value="增加" class="btn_add" onclick="location.href='toAddCost.do';" />
                </div> 
                <!--启用操作的操作提示-->
                <div id="operate_result_info" class="operate_success">
                    <img src="images/close.png" onclick="this.parentNode.style.display='none';" />
                    删除成功!
                </div>
                <!--数据区域:用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                        <tr>
                            <th>资费ID</th>
                            <th class="width100">姓名</th>
                            <th>昵称</th>
                            <th>性别</th>
                            <th>余额</th>
                            <th>创建时间</th>
                            <th>用户名</th>
                            <th class="width50">状态</th>
                            <th class="width200">扣费计算</th>
                        </tr>  
                        
                        <c:forEach items="${costs }" var="c"> 
                        
                        
                        	 <tr>
                            <td>${c.user_ID }</td>
                            <td><a href="fee_detail.html">${c.name }</a></td>
                            <td>${c.nickname }</td>
                            <td>${c.sex }</td>
                            <td>${c.balance }</td>
                            <td>${c.time }</td>
                            <td>${c.user_name }</td>
                            
                            <td>                                
                                <input type="button" value="启用" class="btn_start" onclick="startFee();" />
                                <input type="button" value="修改" class="btn_modify" onclick="location.href='toUpdateCost.do?id=${c.user_ID}';" />
                                <input type="button" value="删除" class="btn_delete" onclick="if(deleteFee()) location.href='delete.do?id=${c.user_ID}';" />
                            </td> 
                        </tr>
                     
                        
                        </c:forEach>
                        	
                    </table>
                </div>
                <!--分页-->
                <div id="pages">
        	        <a href="#">上一页</a>
                    <a href="#" class="current_page">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                    <a href="#">4</a>
                    <a href="#">5</a>
                    <a href="#">下一页</a>
                </div>
            </form>
        </div>
        <!--主要区域结束-->
    </body>
</html>

679

社区成员

发帖
与我相关
我的任务
社区描述
智能路由器通常具有独立的操作系统,包括OpenWRT、eCos、VxWorks等,可以由用户自行安装各种应用,实现网络和设备的智能化管理。
linuxpython 技术论坛(原bbs)
社区管理员
  • 智能路由器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧