issue regarding scrollbar position

Discussion in 'JavaScript' started by sandeep tyagi, May 31, 2005.

  1. #1
    hi
    i am facing some problem while setting scrollbar position at run time in a html table.
    Actually i am having a html table in which no. of row are decided at run time. if at any time on click of any button i need to show any specific row visible on the screen.can anyone help me to find out how much pixel should i down the scroll bar to show any specific position.
     
    sandeep tyagi, May 31, 2005 IP
  2. gumape

    gumape Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You must get the position of your row. If it is not in an absolutly positioned element you can ude the offsetTop property to get its exact position.

    
    function ScrollToRow (idx) {
        var table = document.getElementById ("myTable");
        var top = table.rows[idx].offsetTop;
        document.body.scrollTop = top;
    }
    
    Code (markup):
    more info about scrollTop
     
    gumape, Sep 15, 2009 IP
  3. akash786

    akash786 Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    your java script is not properly saved that why it happens or try again and get the java scrip of scroll bar again that will install the process again it will help you to get less errors.
     
    akash786, Sep 17, 2009 IP