Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Great, This would help you to resolve the issue. Check out the script below,</p> <pre><code>&lt;script type="text/javascript"&gt; function deleteEmployee(){ var empIds = []; $("input[name='empIds']").each(function() { empIds.push($(this).val()); }); console.log(empIds); input_box = confirm("Are you sure you want to delete this Record?"); if (input_box == true) { // Output when OK is clicked // Uncomment this code for check your UI part. // $("input[name='empIds']").each(function() { // $('#' + $(this).val()).remove(); // }); // alert('Record(s) Deleted'); $.ajax({ url : 'reserve.jsp?empIds='+empIds, type : "POST", async : false, success : function() { $("input[name='empIds']").each(function() { $('#' + $(this).val()).remove(); }); alert('Record(s) Deleted'); } }); $('#' + rowid).remove(); alert('Record Deleted'); } else { // Output when Cancel is clicked return false; } } &lt;/script&gt; </code></pre> <p>And in your html part,</p> <pre><code>&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();" /&gt; &lt;/table&gt; </code></pre> <p>Forget about the ajax initially, make sure that you will get correct row id on button click by using <code>console.log(empIds)</code> or <code>alert(empIds);</code> inside your function. Hope you will definitely get this time if your db part is correct. </p>
    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.
    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