0

What I am trying to do is retrieve the information passed from a previous page through and display this within a table on another page.

I have currently got the following code:

PAGE NAME: EMBELLISHMENT
<script>

 var embellishmentlist_var = embellishment;


 var embellishment_explode = embellishmentlist_var.split("#");



for(var i = 1; i < embellishment_explode.length; i++)
            {

            var embellishment_explode_singleinfo =     embellishment_explode.split("_");

              //var table = '<tr><td>' + embellishment_explode[3] + '</td><td>' + data[7] + '</td><td>' + data[1] + '</td><td>' + data[2] + '</td><td>' + data[4] + '</td><td>' + data[5] + '</td>' + data1 + '<td>' + data[9] + '</td></tr>';
                var table = '<tr><td></td></tr>';
                $('#tableshow > tr').append( table );
                //alert(embellishment_explode[4]);
            }


}

</script>


<html>

 <table>

  <tr id="tableshow">
  </tr>

</table>

The foreach can loop round a maximum of 6 times which I hope will create 6 rows within the table however this does not seem to be working. I currently have similar code to the above on another page however the HTML is slightly different. On that page the HTML looks like the following:

 PAGE NAME: INFO

<table id="items_table">
  <th>1</th>
  <th>2</th>
    ///etc
</table>

The Javascript on that page insert rows into the table. This all works.

Therefore the only difference between the two pages is that on the EMBELLISHMENT page I want to create table rows within a table whereas on the INFO page I am creating the complete table.

Could I please have some assistance even if it is just to say it isn't possible.

2
  • You're trying to append table rows to a table row. That's not possible. You could only add rows to a table. Commented Apr 2, 2014 at 11:50
  • 1. as mentioned by alexP, you add row into row $('tr').parent().append(row) 2. row is not direct child of table - there is tableBody in between $('table > tbody > tr') Commented Apr 2, 2014 at 11:54

1 Answer 1

1

You're trying to append table rows to a table row. That's not possible. You could only add rows to a table

HTML

<table id="tableshow"></table>

JS

for(var i = 0; i <= 6; i++){
    $('#tableshow').append('<tr><td></td></tr>');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.