Note that there are some explanatory texts on larger screens.

plurals
  1. POHtml- deleting a row from a database
    primarykey
    data
    text
    <p>I'm trying to delete a row from my MS access database using checkboxes in my HTML/JSP file. The file currently outputs the database to the UI, after the checkbox is ticked and delete is pressed, a prompt pops ups. But I still CAN'T delete the row from my database. Any help would be much appreciated. Thanks. </p> <p>see code below:</p> <pre><code>&lt;%@ page import="java.io.*,java.util.*,java.sql.*"%&gt; &lt;%@ page import="javax.servlet.http.*,javax.servlet.*" %&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;DELETE Operation&lt;/title&gt; &lt;script type="text/javascript"&gt; function deleteEmployee(rowid){ input_box = confirm("Are you sure you want to delete this Record?"); if (input_box == true) { // Output when OK is clicked $('#' + rowid).remove(); alert('Record Deleted'); } else { // Output when Cancel is clicked return false; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;sql:setDataSource var = "bookdB" scope = "session" driver = "sun.jdbc.odbc.JdbcOdbcDriver" url = "jdbc:odbc:bookdB" /&gt; &lt;sql:query dataSource="${bookdB}" var="result"&gt; SELECT * from Employees; &lt;/sql:query&gt; &lt;table border="1" width="100%"&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;Emp ID&lt;/th&gt; &lt;th&gt;First Name&lt;/th&gt; &lt;th&gt;Last Name&lt;/th&gt; &lt;th&gt;Age&lt;/th&gt; &lt;/tr&gt; &lt;c:forEach var="row" items="${result.rows}"&gt; &lt;form method="post" action="reserve.jsp"&gt; &lt;tr id="${row.id}"&gt; &lt;td&gt;&lt;input type = "checkbox" value="${row.id}" name="empIds"&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${row.id}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${row.first}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${row.last}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${row.age}"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/form&gt; &lt;/c:forEach&gt; &lt;input type="button" value="delete" onclick="deleteEmployee('${row.id}');" /&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload