Results 1 to 2 of 2

Thread: Scrollable Table header starts float on click

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

    Default Scrollable Table header starts float on click

    Hi,


    i created a following scrollable Table using some articles on the net


    after creating that I write a script that attch a click event with the table rows so that when ever i click on any row it popup the data of that row in a alert.

    when i scroll down the table and click on any of the row the fixed header of the table goes up after scrolling back to the top and clicking again it comes down please help in this...




    Regards,

    Javascript
    PHP Code:
    <!--
    /* Terence Ordona, portal[AT]imaputz[DOT]com         */
    /* http://creativecommons.org/licenses/by-sa/2.0/    */

    /* begin some basic styling here                     */
    body {
        
    background#FFF;
        
    color#000;
        
    fontnormal normal 12px VerdanaGenevaArialHelveticasans-serif;
        
    margin10px;
        
    padding0
    }

    tabletd{
        
    color#000;
        
    fontnormal normal 12px VerdanaGenevaArialHelveticasans-serif
    }

    h1 {
        
    fontnormal normal 18px VerdanaGenevaArialHelveticasans-serif;
        
    margin0 0 5px 0
    }

    h2 {
        
    fontnormal normal 16px VerdanaGenevaArialHelveticasans-serif;
        
    margin0 0 5px 0
    }

    h3 {
        
    fontnormal normal 13px VerdanaGenevaArialHelveticasans-serif;
        
    color#008000;
        
    margin0 0 15px 0
    }
    /* end basic styling                                 */

    /* define height and width of scrollable area. Add 16px to width for scrollbar          */
    div.tableContainer {
        
    clearboth;
        
    border1px solid #963;
        
    height285px;
        
    overflowauto;
        
    width756px
    }

    /* Reset overflow value to hidden for all non-IE browsers. */
    html>body div.tableContainer {
        
    overflowhidden;
        
    width756px
    }

    /* define width of table. IE browsers only                 */
    div.tableContainer table {
        
    floatleft;
        
    width740px
    }

    /* define width of table. Add 16px to width for scrollbar.           */
    /* All other non-IE browsers.                                        */
    html>body div.tableContainer table {
        
    width756px
    }

    /* set table header to a fixed position. WinIE 6.x only                                       */
    /* In WinIE 6.x, any element with a position property set to relative and is a child of       */
    /* an element that has an overflow property set, the relative value translates into fixed.    */
    /* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */
    thead.fixedHeader tr {
        
    positionrelative
    }

    /* set THEAD element to have block level attributes. All other non-IE browsers            */
    /* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
    html>body thead.fixedHeader tr {
        
    displayblock
    }

    /* make the TH elements pretty */
    thead.fixedHeader th {
        
    background#C96;
        
    border-left1px solid #EB8;
        
    border-right1px solid #B74;
        
    border-top1px solid #EB8;
        
    font-weightnormal;
        
    padding4px 3px;
        
    text-alignleft
    }

    /* make the A elements pretty. makes for nice clickable headers                */
    thead.fixedHeader athead.fixedHeader a:linkthead.fixedHeader a:visited {
        
    color#FFF;
        
    displayblock;
        
    text-decorationnone;
        
    width100%
    }

    /* make the A elements pretty. makes for nice clickable headers                */
    /* WARNING: swapping the background on hover may cause problems in WinIE 6.x   */
    thead.fixedHeader a:hover {
        
    color#FFF;
        
    displayblock;
        
    text-decorationunderline;
        
    width100%
    }

    /* define the table content to be scrollable                                              */
    /* set TBODY element to have block level attributes. All other non-IE browsers            */
    /* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
    /* induced side effect is that child TDs no longer accept width: auto                     */
    html>body tbody.scrollContent {
        
    displayblock;
        
    height262px;
        
    overflowauto;
        
    width100%
    }

    /* make TD elements pretty. Provide alternating classes for striping the table */
    /* http://www.alistapart.com/articles/zebratables/                             */
    tbody.scrollContent tdtbody.scrollContent tr.normalRow td {
        
    background#FFF;
        
    border-bottomnone;
        
    border-leftnone;
        
    border-right1px solid #CCC;
        
    border-top1px solid #DDD;
        
    padding2px 3px 3px 4px
    }

    tbody.scrollContent tr.alternateRow td {
        
    background#EEE;
        
    border-bottomnone;
        
    border-leftnone;
        
    border-right1px solid #CCC;
        
    border-top1px solid #DDD;
        
    padding2px 3px 3px 4px
    }

    /* define width of TH elements: 1st, 2nd, and 3rd respectively.          */
    /* Add 16px to last TH for scrollbar padding. All other non-IE browsers. */
    /* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors        */
    html>body thead.fixedHeader th {
        
    width200px
    }

    html>body thead.fixedHeader th th {
        
    width240px
    }

    html>body thead.fixedHeader th th th {
        
    width316px
    }

    /* define width of TD elements: 1st, 2nd, and 3rd respectively.          */
    /* All other non-IE browsers.                                            */
    /* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors        */
    html>body tbody.scrollContent td {
        
    width200px
    }

    html>body tbody.scrollContent td td {
        
    width240px
    }

    html>body tbody.scrollContent td td td {
        
    width300px
    }
    --> 
    HTML Table
    PHP Code:
    <div id="tableContainer" class="tableContainer">
    <
    table border="0" cellpadding="0" cellspacing="0" width="100%" class="scrollTable">
    <
    thead class="fixedHeader">
        <
    tr>
            <
    th><a href="#">Header 1</a></th>
            <
    th><a href="#">Header 2</a></th>

            <
    th><a href="#">Header 3</a></th>
        </
    tr>
    </
    thead>
    <
    tbody class="scrollContent">
        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>

        </
    tr>
        <
    tr>
            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>
        <
    tr>

            <
    td>Even More Cell Content 1</td>
            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>

            <
    td>And Repeat 3</td>
        </
    tr>
        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>
        </
    tr>

        <
    tr>
            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>Even More Cell Content 1</td>

            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>
            <
    td>And Repeat 3</td>

        </
    tr>
        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>
        </
    tr>
        <
    tr>

            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>Even More Cell Content 1</td>
            <
    td>Even More Cell Content 2</td>

            <
    td>Even More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>
            <
    td>And Repeat 3</td>
        </
    tr>

        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>More Cell Content 1</td>

            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>Even More Cell Content 1</td>
            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>

        </
    tr>
        <
    tr>
            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>
            <
    td>And Repeat 3</td>
        </
    tr>
        <
    tr>

            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>

            <
    td>More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>Even More Cell Content 1</td>
            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>
        </
    tr>

        <
    tr>
            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>
            <
    td>And Repeat 3</td>
        </
    tr>
        <
    tr>
            <
    td>Cell Content 1</td>

            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>

        </
    tr>
        <
    tr>
            <
    td>Even More Cell Content 1</td>
            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>
        </
    tr>
        <
    tr>

            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>
            <
    td>And Repeat 3</td>
        </
    tr>
        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>

            <
    td>Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>

        <
    tr>
            <
    td>Even More Cell Content 1</td>
            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>And Repeat 1</td>

            <
    td>And Repeat 2</td>
            <
    td>And Repeat 3</td>
        </
    tr>
        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>

        </
    tr>
        <
    tr>
            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>
        <
    tr>

            <
    td>Even More Cell Content 1</td>
            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>

            <
    td>And Repeat 3</td>
        </
    tr>
        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>
        </
    tr>

        <
    tr>
            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>Even More Cell Content 1</td>

            <
    td>Even More Cell Content 2</td>
            <
    td>Even More Cell Content 3</td>
        </
    tr>
        <
    tr>
            <
    td>And Repeat 1</td>
            <
    td>And Repeat 2</td>
            <
    td>And Repeat 3</td>

        </
    tr>
        <
    tr>
            <
    td>Cell Content 1</td>
            <
    td>Cell Content 2</td>
            <
    td>Cell Content 3</td>
        </
    tr>
        <
    tr>

            <
    td>More Cell Content 1</td>
            <
    td>More Cell Content 2</td>
            <
    td>More Cell Content 3</td>
        </
    tr>
    </
    tbody>
    </
    table>

    </
    div

  2. #2
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Did you find out how to fix this? I'm having exactly the same issue.

    Thanks.

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
  •