How to find the cell's width and position

Discussion in 'Javascript' started by Asra, Oct 17, 2004.

  1. Asra

    Asra Guest

    Hello,

    I have a table with width as 98% and all cell widths as 120. However,
    these cell widths change with resolution changes. I have to find the
    current cell width and its left position. Is there a browser
    independent way to do that?

    Best Regards,
    Asra Baig
    Asra, Oct 17, 2004
    #1
    1. Advertising

  2. Asra

    Grant Wagner Guest

    Asra wrote:

    > Hello,
    >
    > I have a table with width as 98% and all cell widths as 120. However,
    > these cell widths change with resolution changes. I have to find the
    > current cell width and its left position. Is there a browser
    > independent way to do that?
    >
    > Best Regards,
    > Asra Baig


    When you write the table, use server-side code to divide the number of
    columns by 100 and make each column that percentage wide:

    <table ... width="98%">
    <tr>
    <%
    var numberOfColumns = <some calculation>;
    var columnWidth = Math.floor(100 / numberOfColumns);
    for (var i = 0; i < numberOfColumns; ++i) {
    Response.write(
    '<th width="' + columnWidth + '%">' +
    columnNames +
    '</th>'
    );
    }
    %>
    </tr>

    Now everything will scale nicely regardless of the browser width.

    --
    Grant Wagner <>
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Grant Wagner, Oct 20, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    740
    Bruce Barker
    Oct 10, 2005
  2. news.rcn.com
    Replies:
    1
    Views:
    9,628
    Chris Smith
    Jul 12, 2004
  3. Replies:
    0
    Views:
    503
  4. Empire City
    Replies:
    3
    Views:
    387
    Empire City
    Apr 30, 2004
  5. ted

    Find left position of table cell

    ted, Jan 15, 2005, in forum: Javascript
    Replies:
    2
    Views:
    143
Loading...

Share This Page