Hello There,

Basically I want to print table from javascript.
I have a multidimenational array
global_arrayLength is lenght of that array
In form I have defined an table with below code

<div class='box1' id='show_this' name='show_this'>
    <div id='information-table'><table id='myTable'><tr bgcolor=#ff9966 id='0'>
            <td>Skill Type</td>
            <td>Total Experience Year</td>
            <td>Total Experience months</td>
            <td>Last Used In</td>

and in that table i want to push my array values from javascript as below:

for (var index=0;index < global_arrayLength;index++)
        $("#myTable tr:last").after('<tr>');
        for(inner_index=skill_array[index].length-1;inner_index >=0;inner_index--)
            $("#myTable tr:last").after('<td>'+skill_array[index][inner_index]+'</td>');
        }$("#myTable td:last").after('<td><a onClick=edit_skill('+tr_id+');>'+EDIT+'</td>');

        $("#myTable td:last").after('</tr>');

Here everything goes fine but the <tr>

in firebug it shows code as below:

<tr id="0" bgcolor="#ff9966">
<tr></tr>  <!-- HERE IT SHOULD BE ONLY <tr>  -->
<a onclick="edit_skill(1);">Edit‌·This‌·Skill</a>
<!-- AND HERE THERE SHOULD BE </tr>   -->

How can I do this with my script code i have pasted above?

I want output table as:

Skill Skill Type Total Experience Year  Total Experience months Last Used In  Description    Modify
Lan       C++           0                       1                 May 2014      acsasc    Edit This skil
Lan2      C             4                       6                 May 2012      test2     Edit This skil
3 Years
Discussion Span
Last Post by Priti_P

If you tell jQuery to element.after('<tr>');, the <tr> part is interpreted as "<tr></tr>" (as a whole tag). Therefore you should use another way to create the table you want. For example (with example data):

var table = $('table#table_id');
var tr = $('<tr>');
var td;

// Create a <td> tag, fill it with text and prepend it to the <tr>.
td = $('<td>');
td.html = 'text';

// Create another <td> tag, fill it with text and prepend it to the <tr>.
td = $('<td>');

// Append the <tr> to the table.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.