Javascript 在HTML中向按钮添加操作 沙沃坦列表 资格考试 课程类型 期间 支票数目 课程类别 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 提交

Javascript 在HTML中向按钮添加操作 沙沃坦列表 资格考试 课程类型 期间 支票数目 课程类别 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 英格 基础教学法硕士 其他 PG 提交,javascript,jsp,Javascript,Jsp,这是我的密码 我需要从表中的用户获取输入并添加到数据库中 所有的连接都可以工作 但是sql查询不会导致数据库中的任何更改 我只需要帮助,了解如何对其进行编码,以便在按下“提交”按钮时工作将提交类型添加到按钮: <html> <%@ page import="java.sql.*" %> <head> <title>Sarvotam List</title> <link rel="stylesheet" href="Styles/m

这是我的密码 我需要从表中的用户获取输入并添加到数据库中 所有的连接都可以工作 但是sql查询不会导致数据库中的任何更改
我只需要帮助,了解如何对其进行编码,以便在按下“提交”按钮时工作

将提交类型添加到按钮:

<html>
<%@ page import="java.sql.*" %>
<head>
<title>Sarvotam List</title>
<link rel="stylesheet" href="Styles/main.css">
</head>
<body>
<div class="seg">
    <form action="main.jsp" method="post">
    <table class="data" align="center" width=80%>
        <tr>
            <th width=20%>Qualification Exam</th>       
            <th width=20%>Course Type</th>
            <th width=20%>Duration</th>
            <th width=20%>Number of Cheques</th>
            <th width=20%>Course_Category</th>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
  width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
  width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
  width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
 width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
     width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
  width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
 width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
    width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
            </table>
        <center><button id="submit" name="save">Submit</button></center>

<%              try{
    ResultSet rs=null;
    Statement st=null;
    Connection conn = null;
    Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = 
   DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", 
   "system", "parents94");
            st=conn.createStatement();
            int i=0;
            String s = request.getParameter("save");
            String[] qual=request.getParameterValues("qual");
            String[] ctype=request.getParameterValues("ctype");
            String[] dur=request.getParameterValues("dur");
            String[] noc=request.getParameterValues("che");
            String[] cou=request.getParamterValues("opt");
            if(s!=null)
            while(qual[i].length()!=0){
                st.executeUpdate("insert into SCHOL_COURSE_MASTER values('"+qual[i]+"','"+ctype[i]+"','"+dur[i]+"','"+noc[i]+"','"+cou[i]+"')");
                i++;
            }
        conn.close();
        st.close(); 
            }
catch(Exception e)
    {
        e.getMessage();
    }
%>
</form> 
</div>
  </body>
 </html>

提交

将提交类型添加到按钮:

<html>
<%@ page import="java.sql.*" %>
<head>
<title>Sarvotam List</title>
<link rel="stylesheet" href="Styles/main.css">
</head>
<body>
<div class="seg">
    <form action="main.jsp" method="post">
    <table class="data" align="center" width=80%>
        <tr>
            <th width=20%>Qualification Exam</th>       
            <th width=20%>Course Type</th>
            <th width=20%>Duration</th>
            <th width=20%>Number of Cheques</th>
            <th width=20%>Course_Category</th>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
  width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
  width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
  width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
 width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
     width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
        <tr>
            <td width=20% align="center"><input type="text" name="qual" 
  width=20%></td>
            <td width=20% align="center"><input type="text" name="ctype" 
 width=20%></td>
            <td width=20% align="center"><input type="number" name="dur" 
    width=20%></td>
            <td width=20% align="center"><input type="number" name="che" 
width=20%></td>
            <td width=20% align="center"><select name="opt">
                    <option id="ENG">ENG</option>
                    <option id="MED">MED</option>
                    <option id="OTH">OTH</option>
                    <option id="PG">PG</option>
                </select>
        </tr>
            </table>
        <center><button id="submit" name="save">Submit</button></center>

<%              try{
    ResultSet rs=null;
    Statement st=null;
    Connection conn = null;
    Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = 
   DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", 
   "system", "parents94");
            st=conn.createStatement();
            int i=0;
            String s = request.getParameter("save");
            String[] qual=request.getParameterValues("qual");
            String[] ctype=request.getParameterValues("ctype");
            String[] dur=request.getParameterValues("dur");
            String[] noc=request.getParameterValues("che");
            String[] cou=request.getParamterValues("opt");
            if(s!=null)
            while(qual[i].length()!=0){
                st.executeUpdate("insert into SCHOL_COURSE_MASTER values('"+qual[i]+"','"+ctype[i]+"','"+dur[i]+"','"+noc[i]+"','"+cou[i]+"')");
                i++;
            }
        conn.close();
        st.close(); 
            }
catch(Exception e)
    {
        e.getMessage();
    }
%>
</form> 
</div>
  </body>
 </html>

提交

首先,您可能需要检查 是否触发了单击事件

然后,如果得到正确的值或值不为空,请尝试打印


如果您有错误,最好先将其包含在您的帖子中,您可能需要检查 是否触发了单击事件

然后,如果得到正确的值或值不为空,请尝试打印


如果您有错误,最好将其包含在您的帖子中

没有错误,但它不起作用,您能告诉我如何检查单击事件是否触发编辑是否在检查main.jsp中的数据是否正确没有错误,但它不起作用,您能告诉我如何检查单击事件是否正确吗triggeredit正在检查main.jsp中的数据是否正确表单操作应该是包含要运行的代码的文件表单操作应该是包含要运行的代码的文件DB update相关代码在同一jsp上可用吗?与main.jsp相关的代码在哪里?永远不要在jsp上使用Scriptlet。保留查询日志,并尝试查看将在DB中执行的查询。DB更新相关代码在同一jsp上可用吗?与main.jsp相关的代码在哪里?永远不要在jsp上使用Scriptlet。保留查询日志,并尝试查看将在DB中执行的查询。