删除成功或失败提示:
boolean boo=new BookManageBiz().delete(bm); String info=boo?"删除成功":"删除失败"; String str="<script type=‘text/javascript‘>alert(‘"+info+"‘);window.location.href="+req.getContextPath()+"/findall.do‘;</script>"; PrintWriter out=resp.getWriter(); out.print(str); out.flush(); out.close();
删除询问:
<a href="javascript:mydelete(${b.b_Id})">删除</a> <script type="text/javascript"> function mydelete(id){ if(confirm("你确定要删除吗?")){ window.location.href="/20170519/delete.do?id="+id; } } </script>
输入框验证:
<script type="text/javascript"> window.onload = function() { document.getElementById("myForm").onsubmit = function() { var arr=["b_name","b_author","b_time"]; var a=["图书名称不能为空","作者姓名不能为空","购买日期不能为空"]; for(var i=0;i<arr.length;i++){ if(myId(arr[i]).length==0){ alert(a[i]); return false; } } if(myId("b_time").length>0){ var reg=/\d{4}-([1-12]|\d{2})-([1-9]|\d{2})/; if(!reg.test(myId("b_time"))){ alert("日期格式错误,必须为yyyy-MM-dd"); return false; } } return true; } function myId(id){ return document.getElementById(id).value; } } </script>
时间: 2024-10-13 23:30:21