I have a table which is generated based on user input to a form. That generates rows and cols. I want the nodes to be filled with an image. I am getting the table but nodes are filled with [object HTML image element]? I thiink this is trying to access the image but failing? Here is what I have tried. All help appreciated.
for (r = 0; r < howOften; r++) {
row = table.insertRow(-1);
for (c = 0; c < numDays; c++) {
col = row.insertCell(-1);
img=new Image();
img.src="../www/images/TEST.png";
col.appendChild(document.createTextNode(img));
};
};
You're just pasting the actual text of what the image object contains, which is definitely not what you want to do. Try something like the following.
img.onload = function() { //check to make sure that the image has loaded
col.appendChild(img);
};