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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:14:51+00:00 2026-05-27T06:14:51+00:00

I have a table and I need to get values for each row (in

  • 0

I have a table and I need to get values for each row (in array), something like:
[{1,'test'}, {2,'another test'}, {3, 'nothing'}], but the only I can get is:
["1 test", "2 another test","3 nothing"]. I need to send this values by ajax as json object … and create another table – thus I need an array of values …

var table = $("table");
var rowsAll = table.find("tbody tr");
rowsAll.each(function(i,l) {
    var rows = [];
    $(this).each(function(t,l){
    rows[rows.length] = cells[t]= $(this).text();
    return rows; //returns rows, but I need cells of each row
    }).serialize();//or get()
});

the html is something like this:

<table id="deal">
<thead>
    <tr>
        <th> num </th>
        <th> string </th>
    </tr>
</thead>
<tbody>
    <tr> <td> 1 </td> <td> test </td> </tr>
    <tr> <td> 2 </td> <td> another test </td> </tr>
    <tr> <td> 3 </td> <td> nothing </td> </tr>
</tbody>
</table>

I really need help …

  • 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-27T06:14:51+00:00Added an answer on May 27, 2026 at 6:14 am

    This form of data makes no sense as it’s very hard to read with javascript:

    [{1,'test'}, {2,'another test'}, {3, 'nothing'}]
    

    I’m going to assume that what you want is this:

    {"1": "test", "2": "another test", "3": "nothing"}
    

    To get that second form, you could use this code:

    var results = {};
    $("#deal tbody tr").each(function() {
        var cols = $(this).find("td");
        results[$.trim(cols.eq(0).text())] = $.trim(cols.eq(1).text());
    });
    

    Working example here: http://jsfiddle.net/jfriend00/WjgrC/.

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

Sidebar

Related Questions

I have a table with 11 columns, but I need to get only 2
I have a table of values and need to get the value of a
I have a table with a credit and debit column. I need to get
I need to get the td element of a table. I do not have
I have an exchange rate table. I need to get current rate and previous
I have table to test score data that I need to pivot and I
I have table with an auto-increment field, but I need to transfer the table
I have a table containing a large number of rows. Each row has 2
I have a table of Items, and in each row there is a link
I have a table containing a large number of rows. Each row has 2

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.