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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:41:50+00:00 2026-06-10T10:41:50+00:00

I am building a html table dynamically with Javascript; This is my html table:

  • 0

I am building a html table dynamically with Javascript; This is my html table:

<table class="ui-list" cellpadding="2" id = "tbl">
                <thead>
                    <tr>
                        <th>Artikel ID</th>
                        <th>Artikelnr</th>
                        <th>Bezeichnung</th>
                        <th>Stk.</th>
                        <th><?php echo FW_HTML_Button::build('entfernen', array('onclick' => '' ,'id'=>'get_button')); ?></th>

                    </tr>
                </thead>
                <tbody>
                    <tr>
                    <td></td>
                    <td></td>
                    <td>Gesamt:</td>
                    <td></td>
                    <td>Action:</td>
                    </tr>
                <!-- Fill with JS -->
                </tbody>
            </table>

And this is how I fill it with rows:

         function addRow(tableID) {

                var table = document.getElementById(tableID);

                var rowCount = table.rows.length;
                var row = table.insertRow(rowCount);

                var cell1 = row.insertCell(0);
                var element1 = obj[16][count]["id"]["article_id"];
                cell1.innerHTML = element1;

                var cell2 = row.insertCell(1);
                var element2 = obj[16][count]["id"]["article_no_internal"];
                cell2.innerHTML = element2;

                var cell3 = row.insertCell(2);
                var element3 = obj[16][count]["id"]["article_name_internal"];
                cell3.innerHTML = element3;

                var cell4 = row.insertCell(3);
                cell4.innerHTML = obj[16][count]["stk"];;

                var cell5 = row.insertCell(4);
                var element4 = document.createElement("input");
                element4.type = "checkbox";
                cell5.appendChild(element4);

            }

It works just fine, my only problem is as you can see I already have a row in my html part, and I would like to put the new row, before the row I created in html. For now it always puts the new rows after the row where is written ‘gesamt’ and ‘action’. Is it possible to make this different?

  • 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-10T10:41:52+00:00Added an answer on June 10, 2026 at 10:41 am

    Use

    var row = table.insertRow(rowCount - 1);
    

    instead of

    var row = table.insertRow(rowCount);
    

    (Assuming, of course, that it is guarranteed that you’ll always have that footer row in your table).

    See: http://jsfiddle.net/hwSfG/

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

Sidebar

Related Questions

I'm building a html table dynamically in an ASP.NET code behind file using C#.
I have a huge html table that I am building dynamically, and I want
I'm building a html table using javascript on the fly and I want to
I have an HTML table where I'm building an edit function to change a
I'm building a table with some text that is HTML, so I am using
I am building an HTML Gui builder and this involves round-tripping HTML pages from
I'm parsing out an HTML table and building an array based on the row
I'm building a PHP/HTML front end to a MySQL database. The table I'm attempting
I'm building a web app that displays a list of customers in a table.
class BaseForm(forms.Form): def as_custom_table(self): Returns this form rendered as HTML <tr>s -- excluding the

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.