473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Getting scrollbar line position from textarea?

Here's my problem: I need to present text in a scrolling textarea such
that a checkbox is not enabled until the user has scrolled to the very
last line of the text using the vertical scrollbar.

Been searching for some functions to get scrollbar position for a
textarea object but coming up empty.

A nudge in the right direction would be appreciated. Thanks.

Jul 24 '06 #1
2 11449
I would check out the scrollTop and scrollHeight properties of the
textarea control. The scrollTop will tell you how far down the control
is scrolled, and the scrollHeight tells you the total scrollable length
- I think you would want to handle the onscroll property, and ensure
these values are even.

*** completely untested code snippet ***
<script language="JavaScript">
function myTextArea_OnScroll(myTextArea) {
if (myTextArea.scrollTop == myTextArea.scrollHeight) {
document.getElementById('myCheckBox').disabled = false;
}// end if
} // end myTextArea_OnScroll function
</script>
<textarea onscroll="myTextArea_OnScroll(this);"></textarea>
<input type="checkbox" id="myCheckBox" disabled>

Happy Coding!
Mike Brophy wrote:
Here's my problem: I need to present text in a scrolling textarea such
that a checkbox is not enabled until the user has scrolled to the very
last line of the text using the vertical scrollbar.

Been searching for some functions to get scrollbar position for a
textarea object but coming up empty.

A nudge in the right direction would be appreciated. Thanks.
Jul 25 '06 #2
The scrollTop/onScroll solution is a good one for IE and your code
snippet was much appreciated, however the onscroll event for
Mozilla/Firefox isn't working (it has been filed as a bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=229089).

Upon further research I'm going to use a scrolling DIV layer to display
the text and put a checkbox at the bottom, serving the same purpose
that a user won't see the checkbox unless they have scrolled to the
last line of the DIV layer.

Thanks for your help!

Mike
JustinBlat wrote:
I would check out the scrollTop and scrollHeight properties of the
textarea control. The scrollTop will tell you how far down the control
is scrolled, and the scrollHeight tells you the total scrollable length
- I think you would want to handle the onscroll property, and ensure
these values are even.

*** completely untested code snippet ***
<script language="JavaScript">
function myTextArea_OnScroll(myTextArea) {
if (myTextArea.scrollTop == myTextArea.scrollHeight) {
document.getElementById('myCheckBox').disabled = false;
}// end if
} // end myTextArea_OnScroll function
</script>
<textarea onscroll="myTextArea_OnScroll(this);"></textarea>
<input type="checkbox" id="myCheckBox" disabled>

Happy Coding!
Mike Brophy wrote:
Here's my problem: I need to present text in a scrolling textarea such
that a checkbox is not enabled until the user has scrolled to the very
last line of the text using the vertical scrollbar.

Been searching for some functions to get scrollbar position for a
textarea object but coming up empty.

A nudge in the right direction would be appreciated. Thanks.
Jul 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
11
by: Johnny Two Dogs | last post by:
I'm strictly concerned with IE, so cross-browser compatibilty isn't necessary. If you view the code below, I almost get exactly what I'm looking for: - A table of four cells that...
6
by: Colin McGuire | last post by:
Hello experts, this is a repost but I have been (much) more clear. I want to know the position of the horizontal scrollbar in a textbox as a percentage - if the horizontal scrollbar is hard...
22
by: Colin McGuire | last post by:
I apologize for posting yet another scrollbar question. Here is my code. All I want is for a diagonal line to appear from coordinates (0,0) to (width,height) in a usercontrol regardless of whether...
2
by: musicmouse | last post by:
Happy new year to you all, I have a problem with the css settings for the horizontal scrollbar of a textarea. When I look at my textarea's in Internet Explorer (I use 5.5) I see only a...
5
by: reon | last post by:
Hi friends How can i add a vertical and horizontal scroll bar inside a Textarea.. While i created a textarea i cant read the topics down the screen ... i add a scrollbar but it seperates from...
0
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone! I have these three questions and though to post them in a single thread: 1) I have created a textarea: <textarea id="txtCards" cols="50" rows="15" runat="server" wrap="virtual"...
8
by: honey99 | last post by:
Hi! i have a problem with textarea scrollbar in firefox.In FF it is taking horizantal scrollbar by default??but in IE vertical scrollbar is displaying correctly..I want vertical scrollbar in FF and...
1
by: Nick | last post by:
Hi, I have created a html page from Java and I have added a .js file which can resize a TextArea inside the html on mousedown event. <script src="C:\temp\resize.js"</script> <table<tr><td...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.