• 从页面上灵活增删改查


    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'zeng.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
        
        <script type="text/javascript" src="<%=basePath%>js/zDrag.js"></script>
            <script type="text/javascript" src="<%=basePath%>js/zDialog.js"></script>
      </head>
     
      <body>
     <form method="post" action="Addsss/Addsss_tt.action" id="ss">
     <table width="960" border="1" cellspacing="0" align="center"
                    style="TABLE-LAYOUT: fixed">
    <tr><td width="960" colspan="3" align="center">基本信息</td></tr>
    <tr>            
                    <td style="display:none" colspan="1" width="300">基本信息<input type="hidden" name="systemed.id" id="sysid" value="${systemed.id}"/></td>


    <td style="display:none" colspan="1" width="660">
    <table width="660" border="1" cellspacing="0" align="center"
                    style="TABLE-LAYOUT: fixed">
    <tr>    
                                    <td align="center" width="330px"
                                        style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>
                                        姓名<input type="hidden" name="systemed.name" id="sysname" value="${systemed.name}"/>
                                    </td>
                                    <td align="center" width="330px"
                                        style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>
                                        年龄<input type="hidden" name="systemed.age" id="sysage" value="${systemed.age}"/>
                                    </td>
                    </tr>
    </table>
    </td>

    </tr>


      <tr>
       <td style="border: 1px solid #73C2FF; text-align: left;" colspan="1" width="300">基本信息</td>
       <td colspan="3" width="640">
           <table border="1" cellspacing="0" align="center"
                    style="" width="640">
            
                    <tr>
                                    <td align="center"
                                        style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>
                                        姓名
                                    </td>
                                    <td align="center"
                                        style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>
                                        年龄
                                    </td>
                    </tr>
                        <c:forEach var="systemed" items="${sysed}" varStatus="ss">
                    <tr>
                    <td width="390">${systemed.name}</td>
                    <td  width="390">${systemed.age}</td>
                    <td width="180">
                    <a href="javascript:void(0);"
                                            onclick="upd('${systemed.id}','${systemed.name}','${systemed.age}')">修改</a>
                                        <a href="javascript:void(0);"
                                            onclick="deltable('<%=basePath%>Addsss/Addsss_delSys.action?id=','${systemed.id}');"
                                            style="cursor: pointer;">删除</a>
                                            </td>
                                
                    </tr>
                    </c:forEach>
                    
                    
         </table>
        </td></tr>
        <tr>
        <td colspan="3" width="960">
        <table border="1" cellspacing="0" align="center"
                    style="" width="960">
        <tr>
                    
                    <td align="center"><input type="button" value="增加"
                                            style=" 100px; height: 30px; font-family: 宋体; font-size: 19px; border: none; color: white; "
                                            onclick="openuu();"/></td>
                    </tr>
        </table>
        </td>
        </tr>
        </table>
     </form>
     
        <script type="text/javascript">
        
        function deltable(val1,val2){
        
        document.getElementById("ss").action=val1+val2;
        document.getElementById("ss").submit();
        }
        function openuu(){
       
        var diag=new Dialog();
        diag.Width = 900;
        diag.Height = 150;
        diag.URL = "<%=basePath%>test.html";
        diag.Title = "成功哈哈哈";
        //点击确定后调用的方法
            diag.OKEvent = function(){
                $id('sysid').value = diag.innerFrame.contentWindow.document.getElementById('k').value;
                $id('sysname').value = diag.innerFrame.contentWindow.document.getElementById('a').value;
                $id('sysage').value = diag.innerFrame.contentWindow.document.getElementById('b').value;
                
               save();
        };
        
            diag.OnLoad=function(){
            
            
            };
        diag.show();
        var doc=diag.innerFrame.contentWindow.document;
        doc.open();
        doc.write("<table style='background-color: #E5F5FF;' cellpadding='0'  align='center' cellspacing='0' border='1' width='100%' >"+
                                "<tr>"+
                                "<td align='center' width='100px' style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>基本信息<input type=\"hidden\" id=\"k\" /></td>"+
                                "<td align='center' width='100px' style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>姓名<input type=\"text\" id=\"a\" /></td>"+
                                "<td align='center' width='100px' style='border:1px solid #73c2FF; font-family:宋体; font-size:19px;'>年龄<input type=\"text\" id=\"b\" /></td>"+
                                "</tr>"+
                                "</table>");
            doc.close();
    }


     function upd(val1,val2,val3){
       var diag=new Dialog();
        diag.Width = 900;
        diag.Height = 150;
        diag.URL = "<%=basePath%>test.html";
        diag.Title = "成功哈哈哈";
        //点击确定后调用的方法
            diag.OKEvent = function(){
                $id('sysid').value = diag.innerFrame.contentWindow.document.getElementById('k').value;
                $id('sysname').value = diag.innerFrame.contentWindow.document.getElementById('a').value;
                $id('sysage').value = diag.innerFrame.contentWindow.document.getElementById('b').value;
               save();
        };
            diag.OnLoad=function(){
            diag.innerFrame.contentWindow.document.getElementById('k').value=val1;
            diag.innerFrame.contentWindow.document.getElementById('a').value=val2;
            diag.innerFrame.contentWindow.document.getElementById('b').value=val3;
            };
            
        diag.show();
        var doc=diag.innerFrame.contentWindow.document;
        doc.open();
        doc.write("<table style='background-color: #E5F5FF;' cellpadding='0'  align='center' cellspacing='0' border='1' width='100%' >"+
                                "<tr>"+
                                "<td align='center' width='100px' style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>基本信息<input type=\"hidden\" id=\"k\" /></td>"+
                                "<td align='center' width='100px' style='border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;'>姓名<input type=\"text\" id=\"a\" /></td>"+
                                "<td align='center' width='100px' style='border:1px solid #73c2FF; font-family:宋体; font-size:19px;'>年龄<input type=\"text\" id=\"b\" /></td>"+
                                "</tr>"+
                                "</table>");
            doc.close();
     }
        function save(){
               var name=document.getElementById("sysname").value;
               var age=document.getElementById("sysage").value;
               if(name==null||name==""){
               alert("姓名不能为空");
               return false;
               }
               if(age==null||age==""){
               alert("年龄不能为空");
               return false;
               }else{
               alert("成功");
               }
               document.getElementById("ss").action="<%=basePath%>Addsss/Addsss_zengjia.action"
               document.getElementById("ss").submit();
               }
        </script>
      </body>
    </html>

  • 相关阅读:
    20100720 14:14 转:BW十日谈之标准数据源
    BW会计年度期间转换出错
    SQL Server 2005 Logon Triggers 详细介绍
    作业输出文档维护
    windows 系统监视器 以及建议阀值
    linkedserver 的使用
    DAC 连接数据库需要做些什么
    SQL Server 2008新特性 Merge 详细见联机手册
    【20110406】提高数据库可用性需要注意的问题
    索引迁移
  • 原文地址:https://www.cnblogs.com/zhiguci/p/7047257.html
Copyright © 2020-2023  润新知