SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help Needed with scrollHeight please

    I'm having a heck of a time figuring this out. I've been researching for the past few hours with now luck. I'm not too familiar with javascript. I have a php script that echos out text within a CSS box. The problem is autoscrolling while the text is being put into the box. I've tried several examples online and none of them work. Most of the solutions are for <textarea>, which is not the way I'm doing things.

    I think I'm on the right track within this code:

    Code:
    <script language="javascript" type="text/javascript">
       document.getElementById('divExample').scrollTop=document.getElementById('divExample').scrollHeight;
    </script>
    This being a short example of my CSS text-area:

    Code:
    <div id="divExample" style="width: 315px; height: 200px; overflow:auto; border: 2px solid black;">
    
    <?PHP MY PHP CODE ?>
    
    </div>
    I have played with the CSS overflow style and have not had any success. If anyone has any suggestions I would greatly appreciate it.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I don't see how a PHP script could do this, as it operates on the server side. Do you mean that you want the box to be scrolled down a certain distance by default when the page is loaded? If this is somehow being done every few seconds or something like that, then you need to be performing your javascript every time this happens, as it won't update itself automatically. However, it's hard to tell what you want to do without any more code or an example.

  3. #3
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    I don't see how a PHP script could do this, as it operates on the server side. Do you mean that you want the box to be scrolled down a certain distance by default when the page is loaded? If this is somehow being done every few seconds or something like that, then you need to be performing your javascript every time this happens, as it won't update itself automatically. However, it's hard to tell what you want to do without any more code or an example.
    Correct, php cannot do this. I've been told that Javascript can. As the text is sent to the text box I need to have the textbox autoscroll with the new text instead of remaining at the top. Yes, it is being done every few seconds - that being said I suppose the javascript function needs to be called everytime. However, this seems way too complicated for something so simple.

    I'm giving up at this point.

  4. #4
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an exact example of what I need...

    http://radio.javaranch.com/pascarell...573598403.html


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
  •