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
| 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 January 10th, 2005, 09:36 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default Scrolling Textbox

Hi all,

How do you get a scrolling textbox to scroll down and stay there?

thanks
interrupt

__________________
\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
  #2 (permalink)  
Old January 10th, 2005, 08:13 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

If by "stay there" you mean stay there while you modify the contents, I have researched this and was unable to find a solution :-(

Let us know if you do end up finding a solution.

-Snib - http://www.snibworks.com
Where will you be in 100 years?
Reply With Quote
  #3 (permalink)  
Old January 11th, 2005, 03:54 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

HI Interrupt,
Try this
<input type=text id="myid" STYLE="position:relative; bottom:0px">

<script>
var obj = document.getElementById('myid');
var newposition = parseInt(obj.style.bottom);

function ScrollInput() {
  newposition -= 5;
  document.getElementById('myid').style.bottom=newpo sition + "px";

}
setInterval('ScrollInput()',2000);

</script>

offcourse now you can stop the textbox at particular location, by using onfocus(),onblur() methods.
Also we can stop the textbox at the left bottom,by taking the screen size,isn't it ?
Hope this will help you !!

Cheers :)

vinod
Reply With Quote
  #4 (permalink)  
Old January 11th, 2005, 06:15 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm afraid I got 'Invalid Argument'. This could be because i am using other intervals on the page though. Basically what I have is a rudimentary chat room, that uses timers to send data to and from a text file. This uses the setTimeout method to check for the contents of the textfile and return it to the textarea. The problem being obviously that the textarea doesn't scroll.

Any Ideas?
interrupt

Reply With Quote
  #5 (permalink)  
Old January 11th, 2005, 08:44 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

HI Interrupt!!
Sorry I thought that you want to scroll the textbox/inputbox ,that why i posted the code.
Well you want to set the scrollbars of the textarea so that whenever your textarea is populated ,Current msgs should be shown to the user.
Here is the code,for the moment let "textfile" is the input(it may come form the text file too)
<FORM>
Enter Value <input type=text id=textfile >
<input type=button onclick="check()" value="Add"><br>
<textarea id="myid" cols=80 rows=5> </textarea>

</FORM>
<SCRIPT LANGUAGE="JavaScript">
var i
i=6
function check()
{
obj=document.getElementById("myid")
inputval=document.getElementById("textfile")
if(i==6)
{
obj.value=inputval.value
}
else
{
obj.value=obj.value+"\n"+inputval.value
}
if(i%5==0)
{
i=2*i
}
else
i=i+3
obj.scrollTop=i
}
</SCRIPT>
Hope this will help you,
I have checked it on IE.


Cheers :)

vinod
Reply With Quote
  #6 (permalink)  
Old January 11th, 2005, 09:58 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vinod,

Thanks for your help so far. I already have the chat room built, and I already have the script in place that gets the data from the Textfile. I will include it here. All I need to know is how to get the textarea to scroll to the bottom every time the routine returns the contents of the textfile.

<script language="vbscript">
sub readerText()
dim filesys, readfile, contents
set filesys = CreateObject("Scripting.FileSystemObject")
set readfile = filesys.OpenTextFile("p:\clevedon staff\training program\training pack\chattest\test.txt", 1, false)
contents = readfile.Read(1000000)
readfile.close
document.form1.readit.value = contents & chr(13)
end sub
</script>

As you can see its vbscript, but I just wondered if there was a direct method in Javascript that I could use? Does the textarea have a scroll method?

TYIA
Interrupt



Reply With Quote
  #7 (permalink)  
Old January 11th, 2005, 10:29 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Got it! The way to do it is this:

document.form1.readit.scrolltop = 100 //or a number greater than the height of your textarea!

Thanks for all your help
interrupt

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
scrolling red_fiesta Classic ASP Professional 5 November 2nd, 2006 12:35 PM
Scrolling into TextBox adyrotaru .NET Framework 1.x 2 January 28th, 2006 08:39 AM
scrolling carro123 Javascript How-To 0 June 6th, 2005 12:29 PM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM
scrolling smn2 Classic ASP Professional 1 August 28th, 2003 06:57 AM



All times are GMT -4. The time now is 04:12 AM.


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