Log in

View Full Version : dynamic table size



azqnow
08-03-2006, 03:11 AM
I have two totally unrelated tables that needs to automatically adjust depending on the size of the other...

I tried using document.getElementById('mirroringTable').style.height = document.getElementById('originalTable').offsetHeight

among other things.. is there a better way to do this?

when I put
alert(document.getElementById('originalTable').offsetHeight) it outputs the right height but the problem is

document.getElementById('mirroringTable').style.height

doesn't seem to be getting the values from the equation...

can I just do this in css? a dynamic css code? instead of editing it in <script language="javascript"> ??



Thanks

jscheuer1
08-04-2006, 05:49 AM
When setting dimensions using style, units usually must be specified. The offset dimension is (as you may of noticed) a pure number, so this generally works:

document.getElementById('mirroringTable').style.height = document.getElementById('originalTable').offsetHeight+'px';

However, borders, margins, padding and whatever else you may have might, in some cases, need to be detected and added into the calculation. Usually not though, the offset dimension usually includes those things or they are so small that it makes virtually no difference.