Click here to Skip to main content
15,911,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
Im new to the Html world. I have a Html page that my application load which basically consists of the table formated to be a header for a report.

I would like to add additional tables with data to the page as I use my software.

Im using the following code to add data:

IHTMLDocument2* pDoc = NULL;
IHTMLElement* pBody = NULL;

BSTR htmlBStr = html.AllocSysString();

GetDHtmlDocument(&pDoc);

pDoc->get_body(&pBody);

pBody->put_innerHTML(htmlBStr);

if ( htmlBStr != NULL )
SysFreeString(htmlBStr);


pBody->Release();
pDoc->Release();

The problem is that when I add the table to my existing document is erases everything on the page. I would like it to just add the table to the document.

Thanks for any help
-Derrek
Posted

1 solution

It's doing what you asked. You will need to find the element you want to be the parent of your table, and then set the innerHtml of just that element. is there a get_element, or similar ? You select element by it's id.
 
Share this answer
 
Comments
DerrekCurtis 10-Jan-13 17:19pm    
I guess im probably using this wrong I send it an entire populated table that I simple want displayed on my page. That works but it erases whats already there.

-Derrek
Christian Graus 10-Jan-13 17:23pm    
Like I said, you are setting the html of the WHOLE page to be your table. You're on the right track, but you need an element to be the parent of your table, then you need to find that and set it's innerHtml to be your table.
DerrekCurtis 10-Jan-13 19:09pm    
Can you point me to some code that will fix this problem? Im really stumpted

-Derrek
Christian Graus 10-Jan-13 19:14pm    
http://msdn.microsoft.com/en-us/library/aa752576(v=vs.85).aspx sadly, it seems the only way to select an element is from it's location. You need to be able to find an element to insert your table after it. Not sure why you can't do that.
DerrekCurtis 11-Jan-13 12:14pm    
There has to be a way to auto-insert after exisitn html content. How can I get a pointer to the page without updating everything?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900