p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   Repositioning a scrollable window (http://p2p.wrox.com/showthread.php?t=14340)

Walter G June 17th, 2004 10:08 AM

Repositioning a scrollable window
Hi, I have a table that becomes scrollable after 10 lines. This table can contain hundreds of lines of data. New data is entered in a text area below the table.

After new data is entered and the screen is refreshed I would like to have the last line (new data) visible at the bottom of the table.
The same as if you where to drag the scroll bar to the bottom of the table. I just want this to happen automatically.

Any ideas?


Walter G June 17th, 2004 10:50 AM

Hi I kept searching and found an example that works at http://forums.devshed.com/archive/t-14600
I tested the example and it works just the way I wanted it to.


Here is the code.

This works on IE5.5 and seems to work most of the time on NS 4.7 <html>
<title>Scroll textbox</title>
<script language=javascript>

function scrollTextarea()
{var obj=document.forms.main.elements.text;

var gradual=true; // true to scroll slowly, false to jump


if (document.layers)
else if (gradual)
{var top=-1
while (top<obj.scrollTop)

function fillTextarea()
{var htmlStr="";
for (var i=0;i<100;i++)
{htmlStr+="<h3>Line "+i+"</h3>\n"}

<body bgcolor=black onload="fillTextarea();scrollTextarea();">
<basefont face=arial color=lime>
<h2>Scroll textbox</h2>
<form name=main action=# method=get>
<textarea name=text rows=10>
</html>Not sure how will get on in NS6, but NS6 won't lanuch at the moment to test!!
Referred to msdn (http://msdn.microsoft.com/workshop/c...s/textarea.asp) for dom


All times are GMT -4. The time now is 08:13 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.