views:

42

answers:

2

I am unable to add a row to a HTML table dynamically. I am using IHtmlDocument2 to create tr and td elements and IHtmlElement to set attributes and IHtmlDomNode to add created node to the document hierarchy.

Please anyone help me to solve the above problem.

I am traversing through the document when I get the tr tag I have created the tr element using CreateElement, then I use InsertBefore to insert it into the document but it's not working.

I've tried for one week but didn't get anything working.

+1  A: 

I suggest that you start using a JavaScript framework such a jQuery or Prototype. Either of these will allow you to achieve the functionality with one line of JavaScript code regardless of which browser you have. Using Prototype for example:

$$('table#mytable').insert({bottom: '<tr><td>some html</td></tr>'})
Salman A
A: 

With jQuery it's

$('table#mytable').append('<tr><td>some html</td></tr>');
Patrick Bergner