# Problem in Displaying Textarea

**URL:** <https://www.ruby-forum.com/t/problem-in-displaying-textarea/93271>\
**Category:** Rails\
**Created:** [April 30, 2007, 9:07am UTC](https://www.ruby-forum.com/t/problem-in-displaying-textarea/93271 "2007-04-30T09:07:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 30, 2007, 9:07am UTC](https://www.ruby-forum.com/t/problem-in-displaying-textarea/93271/1 "2007-04-30T09:07:56Z")

</div>

Hi everybody !

I’m newbie to rails. I have a problem to display the Textarea.

As I got some value from mysql database and load this value in a text  
area.  
By defualt the scroll bar for the text area is at the top like in  
browsers. But I want the scroll bar of the text area at the bottom like  
in yahoo & gmail chats ( I mean I want to see the last line of the  
textarea at first. If want to see the first line, then I have to scroll  
to the top.)

Is it possible. The code I used for the textarea as follows.

```
<% @message.each do |ms| %>

   <%= ms.content -%>

<%end%>

```

Where @message = Message.find(:all)

Thanks in advance.  
Regards,  
Veeraa.

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 30, 2007, 10:39am UTC](https://www.ruby-forum.com/t/problem-in-displaying-textarea/93271/2 "2007-04-30T10:39:18Z")

</div>

Hi!  
Just googled and found this on another discussion forum,  
nameofyourtextarea.scrollTop = nameofyourtextarea.scrollHeight;  
Hope this helps,

Thanks and regards,  
Swanand

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 30, 2007, 10:42am UTC](https://www.ruby-forum.com/t/problem-in-displaying-textarea/93271/3 "2007-04-30T10:42:14Z")

</div>

Swanand Deodhar wrote:

> Hi!  
> Just googled and found this on another discussion forum,  
> nameofyourtextarea.scrollTop = nameofyourtextarea.scrollHeight;  
> Hope this helps,
> 
> Thanks and regards,  
> Swanand

Hi swanand!

Thanks for your great help. Thanks lot for getting this info by spending  
your valueable time for me.

Thanks with regards,  
Veeraa.

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 30, 2007, 10:57am UTC](https://www.ruby-forum.com/t/problem-in-displaying-textarea/93271/4 "2007-04-30T10:57:25Z")

</div>

Veera S. wrote:

> Swanand Deodhar wrote:
> 
> > Hi!  
> > Just googled and found this on another discussion forum,  
> > nameofyourtextarea.scrollTop = nameofyourtextarea.scrollHeight;  
> > Hope this helps,
> > 
> > Thanks and regards,  
> > Swanand
> 
> Hi swanand!
> 
> Thanks for your great help. Thanks lot for getting this info by spending  
> your valueable time for me.
> 
> Thanks with regards,  
> Veeraa.

Hi swanand !

I used like this both as follows

and

\<% language=“javascript”\> ch1.scrollTop = ch1.scrollHeight; %\>

in my .rhtml file . But doesn’t work. Any other suggestion.

Regards,  
Veeraa…

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 30, 2007, 11:08am UTC](https://www.ruby-forum.com/t/problem-in-displaying-textarea/93271/5 "2007-04-30T11:08:19Z")

</div>

Hi!  
Can you please check if you are getting any JS error? Since according  
to  
[Element: scrollTop property - Web APIs | MDN](http://developer.mozilla.org/en/docs/DOM:element.scrollTop)  
[http://developer.mozilla.org/en/docs/DOM:element.scrollHeight](http://developer.mozilla.org/en/docs/DOM:element.scrollHeight)  
the  
current code should work  
Thanks and regards,  
Swanand.
