Advanced Search

Results 1 to 2 of 2

Thread: dynamic table size

  1. #1
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default dynamic table size

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,704
    Thanks
    43
    Thanked 3,133 Times in 3,097 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •