单击按钮和复选框更新值

时间:2018-04-13 06:44:42

标签: oracle jsp jsp-tags

高级之一给我一个任务,即当经理检查批准时动态获取用户信息(复选框)并单击提交他的任务应提交并删除表单列表管理器可以检查多个批准(复选框)我写了一个代码(在jsp页面上不使用html)但不明白如何选中哪个复选框基于employee_id如果复选框被选中为true那么只有数据才会更新并从列表中删除这里是我的整个代码即时更新数据基于复选框选择和按钮点击任何人的帮助真的很感激

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.*"%>
<%@page import="java.time.LocalTime"%>
<%@page import="java.time.LocalDate"%>
<%@page import="java.text.*,java.util.Date"%>
<%@page import="java.time.Duration"%>
<%@page import="java.time.Instant"%>
<%@page import="java.util.Scanner"%>



  <%
         String manager_id=request.getParameter("txtemployeeid");
          Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;



        %>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Employee and vendor approve Page</title>
    </head>
    <body>

        <table border="1" align="center">

            <tr>

                <td>FIRST_NAME </td>
                <td>LAST_NAME</td>
                <td>ORGANIZATION_NAME</td>
                <td>EMPLOYEE_ID</td>
                <td>Approve</td>
            </tr>


            <%

                Class.forName("oracle.jdbc.driver.OracleDriver");
          Connection con=DriverManager.getConnection("jdbc:oracle:thin:@172.18.114.213:1821:godb","XE","Spacess");

            statement=con.createStatement();
            String Sql="SELECT FIRST_NAME,LAST_NAME,ORGANISATION_NAME,EMPLOYEE_ID from REGISTRATION_EMPLOYEE where role in ('Employee','Vendor')";
            resultSet=statement.executeQuery(Sql);


while(resultSet.next())
{
    String Employee_id=resultSet.getString("EMPLOYEE_ID");
      %>

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


      <tr>


              <td><%=resultSet.getString("FIRST_NAME")%></td>
              <td><%=resultSet.getString("LAST_NAME")%></td>
              <td><%=resultSet.getString("ORGANISATION_NAME")%></td>
              <td><%=resultSet.getString("EMPLOYEE_ID")%></td>
              <td>
                <input type="checkbox" name="EMPLOYEE_ID" value="${REGISTRATION_EMPLOYEE.EMPLOYEE_ID}" float:left;>
            </td>

      </tr>
</c:forEach>  

<%
    }


    %>
      <tr>
                            <td style="text-align: center">
                                <input type="submit" name="btnApprovevalues" value="Approve" display:block;> &nbsp;<input type="submit" name="btnRejectvalues" value="Reject" display:block;>
                            </td>
                        </tr>

    <%
        String[] selectedStudentIds = request.getParameterValues("EMPLOYEE_ID");
        String btn_approve=request.getParameter("btnApprovevalues");


    if(btn_approve!=null)
    {

        if(selectedStudentIds.equals(true))
        {

        Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con3=DriverManager.getConnection("jdbc:oracle:thin:@172.18.114.213:1821:godb","sbigi_gtrg","Spacess");
              Statement st3=con3.createStatement();

              String Update_Timeout="update REGISTRATION_EMPLOYEE set APPROVE='Y' where APPROVE=N";
              PreparedStatement ps3=con3.prepareStatement(Update_Timeout);
        }
    }
    %>


        </table>
    </body>
</html>

enter image description here

0 个答案:

没有答案