Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

HTMLTableRow - cloneNode, replacing innerHTML resulting in missing <TD> ???

Posted on 2006-04-19
4
Medium Priority
?
1,022 Views
Last Modified: 2008-01-09
Hi
Iam trying to copy an original row with some tag information, then replace these tags with information from my database
The code below is actually working quite good however doing the newRow.innerHTML = newRow.innerHTML (should do nothing) results in the starting <TD> missing
Meaning you get a bad looking table
Does anyone know another way of doing this or what iam doing wrong ?
Additionally i would like a way to delete the originalRow from the html document...

        Dim originalRow As HTMLTableRow
        Dim newRow As HTMLTableRow
        Set originalRow = dd.getElementById("indLinie")
        salg_db.Open "SELECT * From betalinger", frmFront.registerCnxn, adOpenForwardOnly, adLockReadOnly
        While Not salg_db.EOF
            Set newRow = originalRow.cloneNode(True)
            If salg_db!type = 0 Then
                newRow.innerHTML = Replace(Replace(Replace(newRow.innerHTML, "[RegnNavn]", salg_db!tekst), "[RegnBelob]", FormatCurrency(salg_db!tal)), "[Type]", "Indb.")
            Else
                newRow.innerHTML = Replace(Replace(Replace(newRow.innerHTML, "[RegnNavn]", salg_db!tekst), "[RegnBelob]", FormatCurrency(salg_db!tal)), "[Type]", "Udb.")
            End If
            Call originalRow.appendChild(newRow)
            salg_db.MoveNext
        Wend
        salg_db.Close
0
Comment
Question by:mSchmidt
3 Comments
 
LVL 8

Accepted Solution

by:
Leo Eikelman earned 2000 total points
ID: 16491051
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 16494730
I've reproduced your problem and it's rather strange. I tried using the specific table functions from the link above and it did not help either, but maybe because I was missing some additional elements.

This was what I managed and it may help you. A bit sloppy, I know.



    Dim o_doc As HTMLDocument
    Dim o_tbl As HTMLTable
    Dim o_row As HTMLTableRow
    Dim o_rowNew As HTMLTableRow
    Dim o_rowCell As HTMLTableCell
    'get initial elements
    Set o_doc = WebBrowser1.Document
    Set o_row = o_doc.getElementById("row1")
    Set o_tbl = o_row.parentElement.parentElement
    'create new row and cell
    Set o_rowNew = o_doc.createElement("tr")
    Set o_rowCell = o_doc.createElement("td")
    'assign content to the cell and append it to the row
    o_rowCell.innerHTML = "testing"
    Call o_rowNew.appendChild(o_rowCell)
    'insert the new row before the old one and remove the old one
    Call o_row.insertAdjacentElement("beforeBegin", o_rowNew)
    Call o_row.parentNode.removeChild(o_row)

0
 

Author Comment

by:mSchmidt
ID: 16495476
I have managed to get it working using the following code.. it seems that innerHTML should only be used on HTMLTableCells

        Set originalRow = dd.getElementById("udLinie")
        For Each ahv In dDagsInfo.udbetalingCol
            Set newRow = originalRow.cloneNode(True)
            For Each newCell In newRow.childNodes
                newCell.innerHTML = Replace(Replace(Replace(newCell.innerHTML, "[RegnNavn]", ahv.vareNavn), "[RegnBelob]", FormatCurrency(ahv.vareTotal)), "[Type]", "Indb.")
            Next
            Call originalRow.insertAdjacentElement("afterEnd", newRow)
        Next
        Call originalRow.parentElement.removeChild(originalRow)

Thanks for you help though
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question