ShadowMage Posted October 14, 2009 Share Posted October 14, 2009 I've got a table that I'm inserting a group of rows and cells into. The problem is the table header cell won't span the columns. It's only as long as the text that's in it, but I need it to span the entire table.Here is what I've tried: newRow = objTable.insertRow(lastIndex);newCell = newRow.insertCell(0);element = document.createElement("th");element.className = "gridHdr header14pt";//Tried it this way, but to no availelement.colSpan = 7;//Tried this way, too//element.style.width = "100%";element.innerHTML = type+" Type "+index;newCell.appendChild(element); I've also tried this. This spans the cells but the formatting isn't there: newRow = objTable.insertRow(lastIndex);newCell = newRow.insertCell(0);newCell.colSpan = 7;newCell.className = "gridHdr header14pt";newCell.innerHTML = type+" Type "+index; Any advice/help is appreciated, thank you. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 14, 2009 Share Posted October 14, 2009 With the first code, you're trying to add a th to a td. A th doesn't go in a td, a th replaces a td. That would work if you appended the th to the row instead of the cell. Link to comment Share on other sites More sharing options...
ShadowMage Posted October 15, 2009 Author Share Posted October 15, 2009 Ah. Right, thanks for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.