Scrolling to bottom of Textarea


Read With Formatting | Free Open Source Tutorials Account

HTML, JavaScript & CSS
Thread: Scrolling to bottom of Textarea


gabepreston
Hey guys,

Got a question here that I'm hoping someone can answer. I have a <textarea> field in my document that is being fed data from a script as the page loads. The content of the textarea grows rather fast. As such, for the user to view the new data, they have to continually drag the scroll bar down the side to see the newest data as it appears. What I want to do is this- automatically keep the <textarea> scrolling to the bottom so all the new data is shown as it appears. Once the page loads, it will stop scrolling to the bottom of the <textarea> so that the person can now scroll up and down through the data at their leisure. I've spent some time looking around, and I saw some references to the 'scrollTop' object property, but I really don't know if thats right, let alone what to do with it. Any suggestions? Thanks for your time.

-gabriel

md_doc
Sorry gabe I did not see you post this earlier. I am out of town right now but when I get back in town I will post a solution for you. Really not that difficult I do not think depending on if I understand what you are saying or not.

gabepreston
Don't know if you've gotten back from vacation or not yet Doc, but I still haven't had any luck getting this to work. So if you are back, lets see if we can sit down some night and figure this out, or if you want to do it on your own, that's cool too.

md_doc
Gabe... I work out of state Monday - Wednesday but I will stay at work late today and get online and try to hook up with you to figure it out. I will IM you around 6pm or so.

Jasmine
After a considerable search, I have found an answer.
is it relatively simple.

textareaname.scrollTop = textareaname.scrollHeight;

hope this helps

Ezuriah
After a considerable search, I have found an answer.
is it relatively simple.

textareaname.scrollTop = textareaname.scrollHeight;

hope this helps

This sure did for me, thanks for posting it.


~ Ezuriah

Lamer980
OK, here is an out of left field idea, but what about auto hitting the pagedown button a couple of times? when the textarea gets focus, have JS do a key press on the page down button. let me delve and see if i find anything

ashiq88
What I want to do is this- automatically keep the <textarea> scrolling to the bottom so all the new data is shown as it appears. Once the page loads, it will stop scrolling to the bottom of the <textarea> so that the person can now scroll up and down through the data at their leisure.

FredrickGeofry
After a considerable search, I have found an answer.
is it relatively simple.

textareaname.scrollTop = textareaname.scrollHeight;

hope this helps

Its not working Jasmine, i have tried but found no results same as the thing which was as before.

ElfinJohn
After a considerable search, I have found an answer.
is it relatively simple.

textareaname.scrollTop = textareaname.scrollHeight;

hope this helps


I think it will work, let me try and i will let you know about it Jasmine, thanks for help.

NeilHarvey
Its good that you have found the solution Jasmine and hope that it will work for the people.