Problem with the alignment of new element insertion!

D

DaaaDaaa

Hi,

I have a template that has several tables, I need to dynamically add
new elements to one of them, however, I'm having a hard time to append
a new element and some space like <br> after that.

Part of the HTML code look like
<table ID="parent">
<tr>
<td>
<table ID="left">
<tr>
<td>Left navigation one</td>
</tr>
...
</table>
</td>

<td>
<table ID="right">
<tr>
<td>Content here</td>
</tr>
...
add new element here
</table>
</td>
</tr>
</table>

FYI, I don't have a problem adding a new element using
document.createElement function, however, as stated, the new element
was appended to the bottom, instead of, it appears to the right of the
last table.

f = document.getElementById('theForm');
more code for new element addition here ...

// add some space
var b = document.createElement('<br>');
f.appendChild(b);

// try the following does not help either
f.appendChild(document.createElement("<tr><td colspan='2'
height='5'></td></tr>"));

it looks like I need to reference the table object instead of FORM
obj for the above, however, I failed to assign a var to the table
object either by ID or name, would greatly appreciate your help.

TIA.
 
T

Thomas 'PointedEars' Lahn

DaaaDaaa said:
I have a template that has several tables, I need to dynamically add
new elements to one of them, however, I'm having a hard time to append
a new element and some space like <br> after that.

Part of the HTML code look like
<table ID="parent">
<tr>
<td>
<table ID="left">
<tr>
<td>Left navigation one</td>
</tr>
...
</table>
</td>

<td>
<table ID="right">
<tr>
<td>Content here</td>
</tr>
...
add new element here
</table>
</td>
</tr>
</table>

FYI, I don't have a problem adding a new element using
document.createElement function, however, as stated, the new element
was appended to the bottom, instead of, it appears to the right of the
last table.

f = document.getElementById('theForm');
more code for new element addition here ...

There is no element with ID `theForm' in the code you have posted, so I
suggest you post the parts of your code that include the element with
that ID and all its child elements and text nodes, or post the URL of
a test case.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top