Column width calculation in a table
Posted on 2002-05-22
I have 2 tables with the same number of columns and i want to align the columns in the 2 tables. The lower table does not have any restriction on the column width and the browser calculates the size of the column according to the text in the cells. I want to assign these widths from a sample row in the lower table to the columns in the upper table so these 2 tables have the columns aligned.
My question is how do i calculate the width of a column. I am dealing with DOM 2 compliant browsers only so all the DOM methods are good for me. If i try to query the width of any column in the lower table with say col.getAttribute("width") it never returns the value after recalculating the width according to the text in the columns.