Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 17th, 2004, 10:08 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Reply With Quote
  #2 (permalink)  
Old June 17th, 2004, 10:50 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Walter.

Here is the code.

This works on IE5.5 and seems to work most of the time on NS 4.7 <html>
<head>
<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

obj.focus();

if (document.layers)
{obj.select();
obj.blur();
}
else if (gradual)
{var top=-1
while (top<obj.scrollTop)
{top=obj.scrollTop++;}
}
else
{obj.scrollTop=obj.scrollHeight-obj.offsetHeight;}
}

function fillTextarea()
{var htmlStr="";
for (var i=0;i<100;i++)
{htmlStr+="<h3>Line "+i+"</h3>\n"}
document.forms.main.elements.text.value=htmlStr;
}

</script>
</head>
<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>
</textarea>
</form>
</body>
</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

Ed.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrollable Table Options ? asearle XSLT 1 October 28th, 2007 04:11 PM
how to create scrollable datagrid? basant ADO.NET 6 September 11th, 2006 09:55 PM
Scrollable Control - Alternatives? pagates C# 4 April 5th, 2006 03:26 AM
Repositioning Top Left Corner of a Page in print dontknowmuch Java GUI 0 September 30th, 2005 12:05 PM
scrollable window crmpicco Javascript How-To 2 February 11th, 2005 03:56 AM



All times are GMT -4. The time now is 06:03 PM.


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