How can I use innerHTML without delete the before innerHTML?

Posted by Mikelon85 on Stack Overflow See other posts from Stack Overflow or by Mikelon85
Published on 2012-04-03T11:20:33Z Indexed on 2012/04/03 11:30 UTC
Read the original article Hit count: 164

Filed under:
|

I want to convert an Array to a HTML table, but innerHTML deletes it writes before. Here is the code:

<html><div id="tablaP"></div>

function cargar2() {
    document.getElementById('tablaP').innerHTML= "<table>"
    var h=1
    for (i=0;i<miArray.length;i++){ 
        document.getElementById('tablaP').innerHTML = '<tr>'
        for (j=0;j<miArray[i].length;j++){              
            document.getElementById("tablaP").innerHTML = '<td><td>'
        }
        document.getElementById('tablaP').innerHTML = '</tr>'
        h++
    }
    document.getElementById('tablaP').innerHTML = '</table>'
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about table