Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7843653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:37:00+00:00 2026-06-02T16:37:00+00:00

I am using display tag to show user list on my JSP. I have

  • 0

I am using display tag to show user list on my JSP. I have a delete button in each row to delete the particular row/ user from the list. For this I am using ajax.

The user is getting deleted from the database using ajax. But since I am using ajax. Untill I refresh the page the user is still there in the display tag list.

Is there any way i can delete the row from display table using javascript?

As far as I think row can be delted from table using javascript but you need to know row id at least.

So, how do I give unique row ids to each row in the display table?

please help.

Below is my code

<display:table name="employeeUpdateList" pagesize="50" 
    class="listingTable" keepStatus="true" cellpadding="0px"
    cellspacing="0px" id="employeeUpdate" export="true" requestURI="">
    <display:setProperty name="export.decorated" value="true" />
    <display:setProperty name="export.excel.filename"
        value="Employee Update List.xls" />
    <display:column title="What is changed" property="columnName"></display:column>
    <display:column title="From" property="oldValue"></display:column>
    <display:column title="To" property="newValue"></display:column>
    <display:column title="Effective Date">
        <fmt:formatDate value="${employeeUpdate.effectiveDate}"
            pattern="dd MMMM yyyy" />
    </display:column>
    <display:column title="Changed By" property="changedBy.fullname"></display:column>
    <display:column title="Changed On">
        <fmt:formatDate value="${employeeUpdate.changedOn }"
            pattern="dd MMMM yyyy hh:mm:ss" />
    </display:column>
    <display:column media="html"
        style="text-align :center!important;padding:0px!important">
        <input class="input-button-small" type="button"
            value="<spring:message code='button.delete' />"
            onclick="deleteEmployeeUpdate('${deleteEmployeeUpdateUrl}','${employeeUpdate.id}')" />
    </display:column>
    <display:setProperty name="paging.banner.item_name"
        value="Employee Update" />
    <display:setProperty name="paging.banner.items_name"
        value="Employee updates " />
</display:table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:37:02+00:00Added an answer on June 2, 2026 at 4:37 pm

    Update – now that you’ve posted your code, I see you’re using DOM0 onclick="..." handlers. I don’t recommend doing that (see below, this is a classic use case for doing event delegation — watching for clicks at the table level rather than on individual buttons), but..

    You’ll want to modify your deleteEmployeeUpdate function to accept another argument, which will be the button that was clicked. So:

    onclick="deleteEmployeeUpdate(this, '${deleteEmployeeUpdateUrl}','${employeeUpdate.id}')"
    

    and

    function deleteEmployeeUpdate(button, url, id) {
        // ...
    }
    

    Then to remove the row containing the button, within that function:

    var row = button.parentNode;
    while (row && row.tagName.toLowerCase() !== "tr") {
        row = row.parentNode;
    }
    if (row) {
      row.parentNode.removeChild(row);
    }
    

    See below for a solution using event delegation, and below that, some handy reading.


    You don’t need to give your rows IDs. When you process the click event on the delete button, normally you have a reference to that delete button element as this. It has a parentNode property which is the node (element) that contains it. That’s probably a table cell (td). It also has a parentNode property, which is presumably the row (tr), which also has a parent which is usually a tbody, etc.

    You can remove a row by calling its parent node’s removeChild function and passing in the tr element.

    Here’s a complete example: Live copy | source

    HTML:

    <table id="theTable">
      <tbody>
        <tr><td>First row</td><td><button class="delete">Delete</button></td></tr>
        <tr><td>Second row</td><td><button class="delete">Delete</button></td></tr>
        <tr><td>Third row</td><td><button class="delete">Delete</button></td></tr>
        <tr><td>Fourth row</td><td><button class="delete">Delete</button></td></tr>
      </tbody>
    </table>
    

    JavaScript:

    (function() {
    
      // Get a reference to the table
      var theTable = document.getElementById("theTable");
    
      // Watch for clicks
      hookEvent(theTable, "click", function(event) {
        var elm, row, tbody;
        elm = event.target
        while (elm && elm.className !== "delete") {
          elm = elm.parentNode;
        }
        if (elm) {
          // It's the delete button, remove this row
          row = elm.parentNode.parentNode; // Parent of button's parent
          tbody = row.parentNode;
          tbody.removeChild(row);
        }
      });
    
      // === Basic utility functions
    
      function display(msg) {
        var p = document.createElement('p');
        p.innerHTML = String(msg);
        document.body.appendChild(p);
      }
    
      function hookEvent(element, eventName, handler) {
        // Very quick-and-dirty, recommend using a proper library,
        // this is just for the purposes of the example.
        if (typeof element.addEventListener !== "undefined") {
          element.addEventListener(eventName, handler, false);
        }
        else if (typeof element.attachEvent !== "undefined") {
          element.attachEvent("on" + eventName, function(event) {
            return handler(event || window.event);
          });
        }
        else {
          throw "Browser not supported.";
        }
      }
    })();
    

    Reading:

    • DOM2 Core
    • DOM2 HTML
    • DOM3 Core
    • HTML5 Web Application APIs

    FWIW, I’d strongly recommend using a good JavaScript library like jQuery, Prototype, YUI, Closure, or any of several others. The example gets dramatically shorter, which shows how you can focus on what you’re trying to build rather than mucking about with the details of the low-level DOM API.

    For example, the above using jQuery: Live copy | source

    HTML:

    (No change)

    JavaScript:

    jQuery(function($) {
      $("#theTable").on("click", "button.delete", function() {
        $(this).closest("tr").remove();
      });
    });
    

    That’s for jQuery 1.7 and later. If you’re using something earlier, you’d use delegate rather than on (note the order of arguments changes):

    jQuery(function($) {
      $("#theTable").delegate("button.delete", "click", function() {
        $(this).closest("tr").remove();
      });
    });
    

    It would be similarly simple with just about any of the other libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Twitter seems to be using an <i/> tag to display their icons from a
I am actually using h:selectOneRadio to display items, given to it from f:selectItems tag.
I have a problem while returning jsp from controller using ajax+spring mvc. I want
i am using display tag for showing table in my jsp page. I need
In jsp I'm using Display tag to print a table. I want to display
I am using display tag in jsp page. I want to customize the display
I have displaying video using video tag, if user pause the video I am
I'm using the <pre> tag to display preformatted text (including line breaks, spaces and
Using HTML and CSS. I have text surrounded by a border using display:inline to
I have a qTip that I'm using to display data with. It's working great

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.