By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

Scrolling

P: n/a
K.
Hi!

I have such code:

<textarea name="text_field">very long text</textarea>

I have filled in the value of textarea field. This value is a very long
string.
I would like to scroll this textarea field into the end.

Would you like to help me how to do that?

Thank you in advance
M. from Poland
Nov 16 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
Hi!

I have such code:

<textarea name="text_field">very long text</textarea>

I have filled in the value of textarea field. This value is a very long
string.
I would like to scroll this textarea field into the end.
<script ...>
var longStringElement = getElementById("longString");
....

// Whenever you want the textarea to be scrolled to the bottom, do this:
longStringElement.scrollTop = longStringElement.scrollHeight;
</script>
....
<textarea id="longString"...... </textarea>

A.
Nov 16 '06 #2

P: n/a
K.

Użytkownik "Andrew C" <no******@totally.made.upnapisał w wiadomości
news:SG******************@newsfe1-gui.ntli.net...
>
"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
>Hi!

I have such code:

<textarea name="text_field">very long text</textarea>

I have filled in the value of textarea field. This value is a very long
string.
I would like to scroll this textarea field into the end.

<script ...>
var longStringElement = getElementById("longString");
...

// Whenever you want the textarea to be scrolled to the bottom, do this:
longStringElement.scrollTop = longStringElement.scrollHeight;
</script>
...
<textarea id="longString"...... </textarea>

A.


Hi again!

Unfortunately this example doesn`t work on IE.
I have created such code:

<script language=JavaScript>

var biografiaElement = document.getElementById("biografia");
var utworyElement = document.getElementById("utwory");

alert(biografiaElement.scrollHeight);

biografiaElement.scrollTop = biografiaElement.scrollHeight;
utworyElement.scrollTop = utworyElement.scrollHeight;
</script>

Alert gives me 0 height and I don`t know why...

Please help me.
Thank you in advance
Marcin
Nov 16 '06 #3

P: n/a

"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
>
Użytkownik "Andrew C" <no******@totally.made.upnapisał w wiadomości
news:SG******************@newsfe1-gui.ntli.net...
>>
"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
>>Hi!

I have such code:

<textarea name="text_field">very long text</textarea>

I have filled in the value of textarea field. This value is a very long
string.
I would like to scroll this textarea field into the end.

<script ...>
var longStringElement = getElementById("longString");
...

// Whenever you want the textarea to be scrolled to the bottom, do this:
longStringElement.scrollTop = longStringElement.scrollHeight;
</script>
...
<textarea id="longString"...... </textarea>

A.



Hi again!

Unfortunately this example doesn`t work on IE.
I have created such code:

<script language=JavaScript>

var biografiaElement = document.getElementById("biografia");
var utworyElement = document.getElementById("utwory");

alert(biografiaElement.scrollHeight);

biografiaElement.scrollTop = biografiaElement.scrollHeight;
utworyElement.scrollTop = utworyElement.scrollHeight;
</script>

Alert gives me 0 height and I don`t know why...

Please help me.
Thank you in advance
Marcin
Try:

<textarea id="biografia" readonly="true" ...>
....
</textarea>

A.
Nov 16 '06 #4

P: n/a
K.

Użytkownik "Andrew C" <no******@totally.made.upnapisał w wiadomości
news:Pl*******************@newsfe2-gui.ntli.net...
>
"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
>>
Użytkownik "Andrew C" <no******@totally.made.upnapisał w wiadomości
news:SG******************@newsfe1-gui.ntli.net...
>>>
"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
Hi!

I have such code:

<textarea name="text_field">very long text</textarea>

I have filled in the value of textarea field. This value is a very long
string.
I would like to scroll this textarea field into the end.

<script ...>
var longStringElement = getElementById("longString");
...

// Whenever you want the textarea to be scrolled to the bottom, do this:
longStringElement.scrollTop = longStringElement.scrollHeight;
</script>
...
<textarea id="longString"...... </textarea>

A.



Hi again!

Unfortunately this example doesn`t work on IE.
I have created such code:

<script language=JavaScript>

var biografiaElement = document.getElementById("biografia");
var utworyElement = document.getElementById("utwory");

alert(biografiaElement.scrollHeight);

biografiaElement.scrollTop = biografiaElement.scrollHeight;
utworyElement.scrollTop = utworyElement.scrollHeight;
</script>

Alert gives me 0 height and I don`t know why...

Please help me.
Thank you in advance
Marcin

Try:

<textarea id="biografia" readonly="true" ...>
...
</textarea>

A.
Unfortunately this example doesn`t give me a solution I would like to have.
I would like to have textarea element with updating possibilites.

I tried

var elem=document.getElementById("biografia");

if(elem)
{
elem.focus();
MoveToEnd(elem);
elem.focus();
}

but also without results.
I use IE 6.0.

Please help me, I cannot find any properly-working solution in post
archieves
Thank you Andrew for helping
Marcin
Nov 16 '06 #5

P: n/a

"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
>
Użytkownik "Andrew C" <no******@totally.made.upnapisał w wiadomości
news:Pl*******************@newsfe2-gui.ntli.net...
>>
"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
>>>
Użytkownik "Andrew C" <no******@totally.made.upnapisał w wiadomości
news:SG******************@newsfe1-gui.ntli.net...

"K." <ha************@poczta.onet.plwrote in message
news:ej**********@news.onet.pl...
Hi!
>
I have such code:
>
<textarea name="text_field">very long text</textarea>
>
I have filled in the value of textarea field. This value is a very
long string.
I would like to scroll this textarea field into the end.

<script ...>
var longStringElement = getElementById("longString");
...

// Whenever you want the textarea to be scrolled to the bottom, do
this:
longStringElement.scrollTop = longStringElement.scrollHeight;
</script>
...
<textarea id="longString"...... </textarea>

A.


Hi again!

Unfortunately this example doesn`t work on IE.
I have created such code:

<script language=JavaScript>

var biografiaElement = document.getElementById("biografia");
var utworyElement = document.getElementById("utwory");

alert(biografiaElement.scrollHeight);

biografiaElement.scrollTop = biografiaElement.scrollHeight;
utworyElement.scrollTop = utworyElement.scrollHeight;
</script>

Alert gives me 0 height and I don`t know why...

Please help me.
Thank you in advance
Marcin

Try:

<textarea id="biografia" readonly="true" ...>
...
</textarea>

A.

Unfortunately this example doesn`t give me a solution I would like to
have.
I would like to have textarea element with updating possibilites.

I tried

var elem=document.getElementById("biografia");

if(elem)
{
elem.focus();
MoveToEnd(elem);
elem.focus();
}

but also without results.
I use IE 6.0.

Please help me, I cannot find any properly-working solution in post
archieves
Thank you Andrew for helping
Marcin
If you need to add content to the textarea programmatically, readonly won't
stop you, but it does seem to allow the '...scrollTop = ...scrollHeight'
trick to work in IE -- at least it did in IE7 for me.

Only if you need for the user to add content via the keyboard will readonly
cause you difficulties. Even then, one work-around may be to switch readonly
off and on at different times (e.g. set readonly to true briefly when you
add content programmatically and need to auto-scroll to the bottom).

Does this help?

A.
Nov 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.