Is it possible to get the width of table cell(s) that have been dynamically built via JavaScript?

D

douglasc

Goal:

To build a horizontal floating menu that matches the first row (header
row) of my dynamically built table (to include text and cell
height/width - needs to match exactly). I have accomplished 90% of
this task by extracting the text and building the row in my floating
menu header and placing the floating menu where it needs to be.
However, I'm having a problem aligning the table (<TD></TD>) cells
because of my dynamically built table.


Scenario:

I have a table that is built dynamically. Before it is displayed, I
format the table row data (code that adds text/deletes rows etc…),
which alters the width of all the table cells (via JavaScript). We'll
call this (for lack of a better phrase)
"pre_floater_table_format_code."

I then loop through the DOM (<TD></TD>) in the first row of the table
to get the text and width from each cell (using offsetWidth and/or
clientWidth) and assign the text and cell width(s) to variables that I
use to build my floating menu with. We'll call this (for lack of a
better phrase) "get_cell_text_width_code."


Problem:

The problem is that once the table is built (and before it is altered
by the "pre_floater_table_format_code") it seems as though my
"get_cell_text_width_code" reads the un-processed table cell width(s)
and sets these variables to the un-processed width values. The
"pre_floater_table_format_code" runs much earlier than the
"get_cell_text_width_code." So why wouldn't the
"get_cell_text_width_code" read the cell width(s) after they've been
adjusted by the "pre_floater_table_format_code?" Does this make
sense? Anyone have any recommendations? Alternative solutions?



Regards,

Douglas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top