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 6710457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:01:31+00:00 2026-05-26T08:01:31+00:00

I have a table which looks a bit like this: <table> <thead> <tr> <th></th>

  • 0

I have a table which looks a bit like this:

<table>
    <thead>
       <tr>
           <th></th>
           <th>Name</th>
           <th>Email</th>
       </tr>
    </thead>
    <tbody>
        <tr>
            <td class='checkinput'>
                <input type="checkbox" name="names" value="MD5_HASH"/>
            </td>
            <td>
                John Doe
            </td>
            <td>
                email@mail.com
            </td>
        </tr>
        <!-- etc. -->
    </tbody>
</table>

Essentially, I’m trying to build an application where you can select each row in the table that you want, then export the emails to a comma-delimited list. The problem I’m having is how to traverse the table and grab the information I need.

Currently, as a convenience, I’ve done the following to try and make it so that each row, when clicked, toggles the checkbox. Unfortunately, when clicking directly on the checkbox, nothing happens, as it tries to toggle itself as the JavaScript is called, returning it to where it was:

$("tr").click(function() {
    var $checkbox = $(this).find(":checkbox");
    $checkbox.attr('checked', !$checkbox.attr('checked'));
});

How can I optimize this to make it able to click the input itself and not have this conflict occur?

Also, when I’m finally ready to submit, how do I traverse the table and read the email from each row in which the <input> is selected?

  • 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-26T08:01:31+00:00Added an answer on May 26, 2026 at 8:01 am

    [Edited to correct error in first part due to misunderstanding]

    To prevent the undesirable checkbox behavior, exit your handler if the click was directly on the checkbox:

    $("tr").click(function(e) {
        if ($(e.target).is(':checkbox')) return;
        var $checkbox = $(this).find(":checkbox");
        $checkbox.attr('checked', !$checkbox.attr('checked'));
    });
    

    If the event originated from the checkbox, we let the checkbox perform its default behavior. Reference for learning.

    To get the emails on just the checked rows, you should consider setting class="email" on the <td> to make changes easier later on. Then, use something like this:

    var emails = [];
    $("table tbody tr:has(input:checkbox:checked)").each(function(){
       emails.push( $('td.email', $(this)).text() );
    });
    

    Note also that you may want to trim that string to remove undesired whitespace at the beginning and end.

    To learn about selectors used (:checkbox, :checked and :has) see here.

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

Sidebar

Related Questions

I have a table which looks like this: <table id='t'> <thead> .... </thead> <tbody
I have this mysql table called comments which looks like this: commentID parentID type
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have two tables which looks something like this Table Queue int ID; string
i have a table which looks similar to this <asp:TableRow><asp:TableCell>Question 1</asp:TableCell><asp:TableCell ID =Question1Text></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell
i have a table (tbl_world) which look like this id | first_name | last_name
I have a couple of tables which look like this Table 1 user_id |
I have a table which is full of arbitrarily formatted phone numbers, like this
I have a MySQL query that looks like this: UPDATE `Table` SET `Column` =
I have a join in a oracle query which looks like: FROM eiv.table1 eiv.table2

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.