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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:57:15+00:00 2026-06-02T03:57:15+00:00

Assuming I have the following table: <table> <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column

  • 0

Assuming I have the following table:

<table>
  <thead>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>A1</td>
      <td><input type="checkbox"/> A2</td>
      <td>A3</td>
    </tr>
    <tr>
      <td>B1</td>
      <td><input type="checkbox"/> B2</td>
      <td>B3</td>
    </tr>
    <tr>
      <td>C1</td>
      <td><input type="checkbox"/> C2</td>
      <td>C3</td>
    </tr>
  </tbody>
</table>

I want to generate JSON from the table only for the rows whose checkbox is checked. What do I put in for “Insert Check Here”?

var myRows = [];
var $headers = $("th");
var $rows = $("tbody tr").each(function(index) {
  $cells = $(this).find("td");
  myRows[index] = {};
  $cells.each(function(cellIndex) {
    // Insert Check Here
    myRows[index][$($headers[cellIndex]).html()] = $(this).html();
  });    
});

var myObj = {};
myObj.myrows = myRows;
alert(JSON.stringify(myObj));​
  • 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-02T03:57:16+00:00Added an answer on June 2, 2026 at 3:57 am

    I’ve added an If statement to test if the TD contains a checkbox which is checked or not, see the comment in the code

    // Loop through grabbing everything
        var myRows = [];
        var $headers = $("th");
        var $rows = $("tbody tr").each(function(index) {
          $cells = $(this).find("td");
          myRows[index] = {};
          $cells.each(function(cellIndex) {
             if($(this).find('checkbox').is(':checked')) //Find the checkbox within the TD and test if it's checked or not
             {
               myRows[index][$($headers[cellIndex]).html()] = $(this).html();
             }
          });    
        });
    
    // Let's put this in the object like you want and convert to JSON (Note: jQuery will also do this for you on the Ajax request)
    var myObj = {};
    myObj.myrows = myRows;
    alert(JSON.stringify(myObj));​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming I have a column called A and I want to check if A
Assuming I have the following schema table A: ID int primary key value varchar(255)
Assuming I have a SQL Server 2005 table with an xml column containing the
Assuming you have the following database table: create table Names ( Id INT IDENTITY
Assuming that we have the following table: Person: PersonID, Name, Age, Gender And we
Assuming I have the following repeater. <asp:Repeater ID=MyRepeater runat=server onitemdatabound=MyRepeater_ItemDataBound> <FooterTemplate> </table> <asp:Button ID=btnPrevious
Assuming I have a table SomeTable with the following data: Primary Key Column1 Column2
Assuming you have a simple table like the following: +---------+---------------------+ | user_id | activity_date
I want to find the users(userid) from a permissions table who have all of
Assuming the following mappings are provided: <class name=A table=a_table> <id name=id/> <many-to-one name=entityB column=fk_B

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.