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

  • Home
  • SEARCH
  • 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 315439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:17:30+00:00 2026-05-12T08:17:30+00:00

I have a table where i want to be to both select a row

  • 0

I have a table where i want to be to both select a row and delete a row, but i can’t figur out how to do this with JQuery. The code i have only effects the first row in the table. So i can remove the first row but no other. What is wrong. Here is what i tried:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" language="javascript">
    $(document).ready(function() {
        $("#newCandidatesTable").tablesorter();
        var candidateID = $("#candidateID").text();

        // Event actions
        $("#acceptCandidateButton_" + candidateID).click(function(e) {
            $.post("/Admin/AcceptCandidate/", { candidateID: $("#candidateID").text() }, completeAccept());
        });

        // Functions
        function completeAccept() {
            showMsgBox($("#candidateName").text() + " er blevet accepteret, som ansøger til stillingen: ...");
            $("#tr_" + candidateID).remove();
        }

        function getFirstNameFromFullName(fullName) {
            var nameArray = new Array();

            nameArray = fullName.toString().split(" ");

            return nameArray[0];
        }
    });
</script>
<h2>Nye ansøgere</h2>
<table id="newCandidatesTable">
    <thead>
        <tr>
            <th style="cursor: pointer;">ID</th>
            <th style="cursor: pointer;">Navn</th>
            <th style="cursor: pointer;">Email</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
<% foreach (var candidate in Model)
{
     %>
        <tr id="<%= "tr_" + candidate.iAnsogerID %>">
            <td><div id="candidateID"><%= candidate.iAnsogerID %></div></td>
            <td><div id="candidateName"><%= candidate.vNavn %></div></td>
            <td><div id="candidateEmail"><%= candidate.vEmail %></div></td>
            <td>
                <div id="<%= "acceptCandidateButton_" + candidate.iAnsogerID %>" style="cursor: pointer; border: 1px solid black; width: 150px; text-align: center;">Godkend</div>
            </td>
        </tr>
     <%
} %>
</tbody>
</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-05-12T08:17:30+00:00Added an answer on May 12, 2026 at 8:17 am

    I think you need to wrap your event hookup in a foreach to iterate over the collection of items you have.

    $("#candidateID").each(function() {
      // Event actions
      var candID = this.text;
      $("#acceptCandidateButton_" + candID).click(function() {
        $.post("/Admin/AcceptCandidate/", { candidateID: candID }, completeAccept());
      });
    });
    

    I’ve not had the chance to test this but if nothing else it should get you on the right track.

    I guess you could also do this directly in your page generation loop, i.e.:

    <td>
      <div id="<%= "acceptCandidateButton_" + candidate.iAnsogerID %>" style="cursor: pointer; border: 1px solid black; width: 150px; text-align: center;" onclick="$.post("/Admin/AcceptCandidate/", { candidateID: " + candidate.iAnsogerID + " }, completeAccept())">Godkend</div>
    </td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have users table and i have posts table i want select from users
I have table with 3 columns A B C. I want to select *
I have two jobs pulling from a mysql table. They both want to get
Similar: How can I delete duplicate rows in a table I have a feeling
I have two tables: orders and orders_items. Both sharing the field orderID. I want
I have a table and I want to duplicate specific rows in the table.
I have a table where i want to change cell background on mouse over
I have a large table I want to include in a LaTeX document. It
i have a table where i want to track time so a valid entry
I have a table that i want to highlight during onmouseover/onmouseout. I already know

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.