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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:55:53+00:00 2026-05-26T18:55:53+00:00

I’ve been having a hard time trying to append new headers to tables I

  • 0

I’ve been having a hard time trying to append new headers to tables I build dynamically using data grabbed from an AJAX call.

I’ve already asked here a question about my problem, but it seems that there’s no logical answer to it.

So my problem is that I can’t actually get the table I want to append my new info to, what I tired was this:

console.log(id); //This prints the right id!
//THIS is not working...
$('#'+id+' tr:first').append("<td>Well "+(wellCounter)+"</td>");
//...
//$('#'+401+' tr:first').append("<td>Well "+(wellCounter)+"</td>");--this will work
table+="<td>M "+fourthLevel.male+"</td>";
table+="<td>H "+fourthLevel.herm+"</td>";

But it didn’t work, so I was wondering if you can help me with another way to get the same functionality without using the id to get the table. Maybe the closest function will work but I don’t have experience with that, and I tried it but failed.

Here the full code:

    $.each(data, function(index, firstLevel) {
        $.each(firstLevel, function(index2, secondLevel) {
            var id = firstLevel['id'];
            var author = firstLevel['author'];
            var date = firstLevel['date'];
            var experimental_conditions = firstLevel['experimental_conditions'];
            if(index2 == 'items'){                      
                var table = '<div class=tableWrapper><table id=\"'+id+'\" class=\"experimentTable\">';
                table += '<input id=\"basketButton\" type=\"submit\" value=\"Add to basket\" class=\"basketButton\" experimentBatch=\"'+id+'\"> <div class="superHeader"><span class=\"superHeader\">Date: '+date+', By '+author+'</span><br /><span class=\"subHeader\">Experimental conditions: '+experimental_conditions+'</span>'
                table += '<tr><td></td><td COLSPAN=2>Totals</td></tr>';
                table += '<tr id="header"><td width="20%">Genotype</td><td width="10%"><img src="images/herma.png"></td><td width="10%"><img src="images/male.png"></td>';

                //for each table
                $.each(secondLevel, function(index3, thirdLevel) {
                    var nWells = 0;
                    table += "<tr><td><a href=\"wells.html?mutant="+thirdLevel.mutant_name_c+"&rnai="+thirdLevel.rnai_sequence_id_c+"&date="+thirdLevel.date_c+"&author="+author+"\" id=\"getWindow\">"+thirdLevel['mutant_name_c']+"</td><td>"+thirdLevel['herm_total']+"</td><td>"+thirdLevel['male_total']+"</a></td>";
                    currentRow = 3;
                    wellCounter = 0;
                    //for each row
                    $.each(thirdLevel, function(index4, fourthLevel) {
                        wellCounter++;
                        if (fourthLevel.date_r != undefined){
                            console.log(id);
                            //THIS is not working...
                            $('#'+id+' tr:first').append("<td>Well "+(wellCounter)+"</td>");
                            //...
                            table+="<td>M "+fourthLevel.male+"</td>";
                            table+="<td>H "+fourthLevel.herm+"</td>";
                        }
                    });
                });
                table +='</table></div>'
                $('#searchResults').append(table);
            }
        });
    });

NOTE: Male and herm are worm genders, not options!

  • 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-26T18:55:54+00:00Added an answer on May 26, 2026 at 6:55 pm

    I didn’t go through your code, but when I’m working with dynamic table in jquery i try with Jquery “OBJECT”. something like

    var $tbl = $('<table />'), $tr=$('<tr />'), $td=$('<td />');
    

    then you can add attr, append etc, and is much easier to read, and manipulate.

    $tbl.attr('id',id).append($tr.append($td);
    

    etc.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.