473,769 Members | 6,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11499
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="JavaS cript">
function myTextArea_OnSc roll(myTextArea ) {
if (myTextArea.scr ollTop == myTextArea.scro llHeight) {
document.getEle mentById('myChe ckBox').disable d = false;
}// end if
} // end myTextArea_OnSc roll function
</script>
<textarea onscroll="myTex tArea_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="JavaS cript">
function myTextArea_OnSc roll(myTextArea ) {
if (myTextArea.scr ollTop == myTextArea.scro llHeight) {
document.getEle mentById('myChe ckBox').disable d = false;
}// end if
} // end myTextArea_OnSc roll function
</script>
<textarea onscroll="myTex tArea_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
3989
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 nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
11
12387
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 expands/contracts to the width of the browser window. When it contracts, the cell never gets smaller (in width) than the largest DIV item. - When the DIV elements dynamically change, the table cells remain the same in width (and as a result, the left...
6
10939
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 left, I want to display 0% on the form. - if the horizontal scrollbar is smack in the middle, I want to display 50% on the form. - if the horizontal scrollbar is 2/3rd along the X-axis,
22
2357
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 the user autoscrolls the usercontrol (other things that are on the usercontrol I want to scroll, but haven't included any here). Here are the steps to reproduce my problem. 1. Launch Visual Studio and create a new Windows application with...
2
104909
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 vertical scrollbar when the area contains a too long text. IE wil just break off the text at the limit if a single word is too long and put the next character on the next line. For me this is the desired bahaviour (those horizontal scrollbars take too...
5
3288
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 textarea , i want to attach that scrollbar with my textarea how is it possible... JTextArea area = new JTextArea(40,40); JScrollBar scr = new JScrollBar();
0
1622
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" /> which is used for user editing (typing in some info).
8
14034
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 how to avoid horizantal scrollbar in FF??check my code plz.... <TEXTAREA Name="text" rows=4 Cols="70"rows=4 Cols="70" onfocus="focuscolor(this)" onblur='javascript:blurcolor(this);' class="input" wrap="VIRTUAL"> regards
1
1614
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 onmousedown="javascript:resize('trinput',event)"> <TEXTAREA NAME="input" id="trinput" COLS=40 ROWS=60> my textarea here </TEXTAREA>
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.