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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:43:27+00:00 2026-06-19T01:43:27+00:00

My example : http://jsfiddle.net/C7jTg/ var data = [{ id: 1, libelle: 1, ordre: 1

  • 0

My example :
http://jsfiddle.net/C7jTg/

var data = [{
  "id": "1",
  "libelle": "1",
  "ordre": "1"
}, {
  "id": "2",
  "libelle": "2",
  "ordre": "2"
}, {
  "id": "3",
  "libelle": "3",
  "ordre": "3"
}, {
  "id": "4",
  "libelle": "4",
  "ordre": "4"
}, {
  "id": "5",
  "libelle": "5",
  "ordre": "5"
}, {
  "id": "6",
  "libelle": "6",
  "ordre": "6"
}, {
  "id": "7",
  "libelle": "7",
  "ordre": "7"
}, {
  "id": "8",
  "libelle": "8",
  "ordre": "8"
}, {
  "id": "9",
  "libelle": "9",
  "ordre": "9"
}, {
  "id": "10",
  "libelle": "10",
  "ordre": "10"
}, {
  "id": "11",
  "libelle": "11",
  "ordre": "11"
}, {
  "id": "12",
  "libelle": "12",
  "ordre": "12"
}, {
  "id": "13",
  "libelle": "13",
  "ordre": "13"
}, {
  "id": "14",
  "libelle": "14",
  "ordre": "14"
}, {
  "id": "15",
  "libelle": "15",
  "ordre": "15"
}, {
  "id": "16",
  "libelle": "16",
  "ordre": "16"
}, {
  "id": "17",
  "libelle": "17",
  "ordre": "17"
}, {
  "id": "18",
  "libelle": "18",
  "ordre": "18"
}, {
  "id": "19",
  "libelle": "19",
  "ordre": "19"
}, {
  "id": "20",
  "libelle": "20",
  "ordre": "20"
}, {
  "id": "21",
  "libelle": "21",
  "ordre": "21"
}, {
  "id": "22",
  "libelle": "22",
  "ordre": "22"
}, {
  "id": "23",
  "libelle": "23",
  "ordre": "23"
}, {
  "id": "24",
  "libelle": "24",
  "ordre": "24"
}];

$('.activiteTable').append("<tr><td align='center' colspan='4'>&nbsp;</td></tr>" +
  "<tr>" +
  "<td align='left' colspan='4'><b>Title:</b></td>" +
  "</tr>");
var rowActivities = '';

$.each(data, function(i, obj) {
  if (i % 4 == 0) {
    rowActivities += "<tr>";
  }

  rowActivities += "<td align='left'>" +
    "<input type='checkbox' id='todo" + i + "' value='" + obj.id + "' class='chBox'/> " + obj.libelle +
    "</td>";

  if ((i % 4 == 0) || (i == 23) && i != 0) {
    rowActivities += "</tr>";
  }


});
$('.activiteTable').append($(rowActivities));
<table cellspacing="3" cellpadding="3" align="left" class="activiteTable" style="clear:both"></table>

I have a problem understanding how work each function when I generate html tr.

I would like extract JSON data in html table like this model:

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

17 18 19 20

21 22 23 24

I don’t know the best practice.
I hope you help me.

  • 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-19T01:43:29+00:00Added an answer on June 19, 2026 at 1:43 am

    You can simplify this by doing this:

    var rowActivities = "<tr><td align='center' colspan='4'>&nbsp;</td></tr>"
    + "<tr>"
    + "<td align='left' colspan='4'><b>Title:</b></td>"
    + "</tr>"
    + "<tr>";
    $.each(data, function (i, obj) {
        if (i > 0 && i % 4 == 0) {
            rowActivities += "</tr><tr>";
        }
        rowActivities += "<td align='left'>" +
            "<input type='checkbox' id='todo" + i + "' value='" + obj.id + "' class='chBox'/> " + obj.libelle +
            "</td>";
    });
    rowActivities += "</tr>";
    $('.activiteTable').append(rowActivities);
    

    Makes it so you only append to .activeTables once.
    There is no need to convert rowActivities in a jQuery object before passing it to the append() method.

    http://jsfiddle.net/petersendidit/C7jTg/1/

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

Sidebar

Related Questions

Example http://jsfiddle.net/Rg8rf/ $(#label).change(function() { var src = $(this).data('value'); alert(src); }); How do I grab
Here an example http://jsfiddle.net/NuzDj/ If you resize windows size, sidebar overlapping the wrapper &
So I have code like this: $(.list).append('<li>hi</li>'); Here's a working example: http://jsfiddle.net/pXaSC When you
In this example: http://jsfiddle.net/6L6ZL is possible align to right the text of label without
Please check example http://jsfiddle.net/FuFHe/7/ When I click on button Show Data loader div should
I saw the following drop-up menu example: http://jsfiddle.net/W5FWW/360/ html: <div id=menu> <ul> <li><center><a href=#>Home</a></center>
I'm follow this example http://jsfiddle.net/simpulton/XqDxG/ , also find here http://youtu.be/1OALSkJGsRw var myModule = angular.module('myModule',
Working example: http://jsfiddle.net/JVVcA/ HTML: <fieldset id=data-page> <legend>data-page</legend> <button rel=page1>Highlight page one</button> <button rel=page2>Highlight page
Example: http://jsfiddle.net/dfcyb/ I have these two vars var inview = '#' + $(#container >
In this example http://jsfiddle.net/czwsK/ how would I align the text hello to be 10%

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.