1

I have the following code meant to be used in an HTA file for Windows systems. However, the table is not updating with the new rows. Is there a workaround? The same code works fine in a Chrome browser.

<!DOCTYPE html>
<HTML>
    <HEAD>
        <meta http-equiv="MSThemeCompatible" content="Yes"/>
        <TITLE>
            Protos Changer
        </TITLE>
        <HTA:APPLICATION
            ID = "oApp"
            APPLICATIONNAME = "Protos Changer"
            BORDER = "thick"
            CAPTION = "yes"
            ICON = "hw.ico"
            SHOWINTASKBAR = "yes"
            SINGLEINSTANCE = "no"
            WINDOWSTATE = "normal"
            SCROLL = "no"
            SCROLLFLAT = "yes"
            VERSION = "1.1"
            INNERBORDER = "no"
            SELECTION = "no"
            SYSMENU = "yes"
            MAXIMIZEBUTTON = "yes"
            MINIMIZEBUTTON = "yes"
            NAVIGABLE = "yes"
            CONTEXTMENU = "no"
            BORDERSTYLE = "thin"
        />
        <SCRIPT type="text/javascript">
            function init()
            {
                print_stuff('label 1', 'value 1')
                print_stuff('label 2', 'value 2')
                print_stuff('label 3', 'value 3')
                print_stuff('label 4', 'value 4')
                print_stuff('label 5', 'value 5')
                print_stuff('label 6', 'value 6')
            }
            function print_stuff(row_label, row_value)
            {
                var tbl_row = document.createElement('tr')
                var tbl_lbl = document.createElement('td')
                var tbl_val = document.createElement('td')
                var txt_lbl = document.createTextNode(row_label)
                var txt_val = document.createTextNode(row_value)
                tbl_lbl.appendChild(txt_lbl)
                tbl_val.appendChild(txt_val)
                tbl_row.appendChild(tbl_lbl)
                tbl_row.appendChild(tbl_val)
                document.getElementById('page_table').appendChild(tbl_row)
            }
        </SCRIPT>
        <STYLE TYPE="text/css">
        <!--
            body        {background:buttonface;color:buttontext;font:10pt Arial;overflow:hidden;}
            select      {}
            #page_table,td  {border:solid 2px #000;}
            td      {width:10em;height:2em;}
        -->
        </STYLE>
    </HEAD>
    <BODY onload="init()">
        <table id="page_table">
            <tr>
                <td>Label</td>
                <td>Value (old)</td>
            </tr>
        </table>
    </BODY>
</HTML>
posfan12
  • 2,541
  • 8
  • 35
  • 57

1 Answers1

1

I found the solution here:

Can't dynamically add rows to a <TABLE> in IE?

The solution was to create a TBODY element and append the rows to it instead of the TABLE element.

Community
  • 1
  • 1
posfan12
  • 2,541
  • 8
  • 35
  • 57