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

  • Home
  • SEARCH
  • 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 7368033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:36:48+00:00 2026-05-29T03:36:48+00:00

I have a problem adding the data array into my table. There is no

  • 0

I have a problem adding the data array into my table. There is no error message shown in the firebug and the data was not added into the table as rows using the $("#tbNames tr:last").after("<tr><td>" + data[0] + "</td><td>" + data[2] + "</td><td><img src='delete.gif' class='delete' height='15' /></td></tr>");.

The Logic (Javascript)

<script type="text/javascript">
var data = [];
data.push("Coco", "Mandy");
data.push("Suzze", "Candy");
data.push("Janny", "Jacky");


$(document).ready(function() {
     $('#btnAdd').live('click', function() {
        var name = $('#txtName').val();
        var name2 = $('#txtName2').val();
        $("#tbNames tr:last").after("<tr><td>" + name + "</td><td>" + name2 + "</td><td><img src='delete.gif' class='delete' height='15' /></td></tr>");
     });

     $('#tbNames td img.delete').live('click', function() {
        $(this).parent().parent().remove();
     });

     $("#insert_data").click(function() {
            for(var i=0; i<data.length; i++){
        $("#tbNames tr:last").after("<tr><td>" + data[0] + "</td><td>" + data[2] + "</td><td><img src='delete.gif' class='delete' height='15' /></td></tr>");
        }
     });      
});
</script>

The HTML form

<input id="txtName" type="text" />
<input id="txtName2" type="text" />
<input id="btnAdd" type="button" value="Add" />
<table id="tbNames" border="1" >
     <tr>
         <th>Name</b></th>
         <th>Name2</b></th>
         <th>Delete</b></th>
      </tr>
      <tr>
         <td>Bingo</td>
         <td>Tingo</td>
         <td><img src="Delete.gif" height="15" class="delete" /></td>
      </tr>
</table>
<input id="insert_data" type="button" style="height: 35px; width: 225px" value="Retrieve Default User" />

Please advise if I miss out anything. Thanks.

The Solution

(Will be insert into the solution text area tomorrow since I got this message Users with less than 100 reputation can't answer their own question for 8 hours after asking. You may self-answer in 7 hours. Until then please use comments, or edit your question instead.

Bug 1

Changing the

data.push("Coco", "Mandy"); 
data.push("Suzze", "Candy"); 
data.push("Janny", "Jacky"); 

to

data.push(["Coco", "Mandy"]); 
data.push(["Suzze", "Candy"]); 
data.push(["Janny", "Jacky"]);

Bug 2

Changing the

$("#insert_data").click(function() { 
   for(var i=0; i<data.length; i++){ 
        $("#tbNames tr:last").after("<tr><td>" + data[0] + "</td><td>" + data[2] + "</td><td><img src='delete.gif' class='delete' height='15' /></td></tr>"); 
    } 
}); 

to

$("#insert_data").click(function() { 
    for(var i=0; i<data.length; i++){ 
        $("#tbNames tr:last").after("<tr><td>" + data[i][0] + "</td><td>" + data[i][1] + "</td><td><img src='delete.gif' class='delete' height='15' /></td></tr>"); 
    } 
});
  • 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-29T03:36:49+00:00Added an answer on May 29, 2026 at 3:36 am

    The data arrary contains: [‘Coco’,’Mandy’,’Suzze’,’Candy’,’Janny’,’Jacky’]

    So, currently your code produces:

    <tr><td>Coco</td><td>Suzze</td><td><img ...etc></td></tr>
    <tr><td>Coco</td><td>Suzze</td><td><img ...etc></td></tr>
    <tr><td>Coco</td><td>Suzze</td><td><img  ...etc
    

    Did you mean to write:

    $("#insert_data").click(function() {
      for(var i=0; i<data.length-1; i=i+2){
        $("#tbNames tr:last").after("<tr><td>" + data[i] + "</td><td>" + data[i+1] + "</td><td><img src='delete.gif' class='delete' height='15' /></td></tr>");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem while incrementing a variable and adding new data to array
hi i have a problem about adding data into two tables, heres the situation,
I have a problem adding ADO.Net Entity Data Model to my existing project, or
I have a problem of adding elements into an ArrayList. Each time I do
I have a problem adding entities to a collection. public void SaveNotificationUsergroups(int bookingobjectID, int[]
I have some problem with my .htaccess file. Here I am adding my problem.
I have problem when I try insert some data to Informix TEXT column via
I have problem in adding autocomplete plugin to multiple text inputs in loop (no
The problem is that only some of the XML data is being Inserted into
Right now I have a 2d string array holding my data: //...find number of

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.