views:

57

answers:

1

I create a table programmatically in javascript like this and do a innerhtml on a div. It works fine in firefox but IE screws things up. Obviusly the sucker exists in IE. But when I inspect the thing in IE8 I see that a class and a id on link element is without ", but they should be there. Can these be the problem?

    var create_table = function(rows, len, bilder, texter, mediaids, url) {
    var table = '<table>';
    for (var i = 0; i < len; i++) {
        if (i % rows == 0) {
            table += '<tr>';
        }
        table += '<td><h4><a id="' + mediaids[i].toString() + '" class="medialinks" href="#" >' + texter[i].toString() + '</a></h4><img src="' + bilder[i] +  '" ><td>';
        if (i % rows == rows) {
            table += '</tr>';
        }
    }
    table += '<table>';
    return table; 
}

Can anyone spot an error?

+2  A: 

I don't know if you are want to validate XHTML or HTML, but here are the errors I spotted :

  • your are missing a / to close table, should be </table> not <table>
  • same error for <td>
  • <img> should be closed too />
Soufiane Hassou
thanks. No img should not be closed if you do HTML 4.
poo