473,466 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Revealing the position of the cursor in a text-area

PeP
Good morning,
I have a form containing a text-area,
I'd like to know if it exists a function that, when I activate an event,
returns the position of the cursor in the text-area.

For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.

I hope I was clear.
Thanks in advance to all readers
Jul 23 '05 #1
3 4879
"PeP" <io****@inwind.it> wrote in message news:<4J*********************@twister2.libero.it>. ..
Good morning,
I have a form containing a text-area,
I'd like to know if it exists a function that, when I activate an event,
returns the position of the cursor in the text-area.

For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.


Having just had to do this for an intranet page where we wanted
to be able to click on terms in a list and have them insert into
a textarea at the cursor position (for an internal wiki), I can
tell you that it is possible, but only in IE unless you replace
the textarea with a _Java_ based editor.

See http://www.faqts.com/knowledge_base/...d/1052/fid/130
for a starting point. The IE code appears to be based on Microsoft's
own code at http://msdn.microsoft.com/library/de...am12032001.asp
(see "O Cursor Where art thou?")

This works, but it's not very nice or easy.
Jul 23 '05 #2
PeP
"MikeT" <ne**@chthonic.f9.co.uk> ha scritto nel messaggio
news:af**************************@posting.google.c om...
"PeP" <io****@inwind.it> wrote in message news:<4J*********************@twister2.libero.it>. ..
Good morning,
I have a form containing a text-area,
I'd like to know if it exists a function that, when I activate an event,
returns the position of the cursor in the text-area.

For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.


Having just had to do this for an intranet page where we wanted
to be able to click on terms in a list and have them insert into
a textarea at the cursor position (for an internal wiki), I can
tell you that it is possible, but only in IE unless you replace
the textarea with a _Java_ based editor.

See http://www.faqts.com/knowledge_base/...d/1052/fid/130
for a starting point. The IE code appears to be based on Microsoft's
own code at

http://msdn.microsoft.com/library/de...us/dnwebteam/h
tml/webteam12032001.asp (see "O Cursor Where art thou?")

This works, but it's not very nice or easy.


Thank you Mike, I'm afraid I posted a FAQ (since 1998) and I'm sorry
in fact I found the same solutions you provide, doing a simple search with
Google.
Anyway I appreciate your attention and suggestion

Best regards
Jul 23 '05 #3
PeP
[cut]
For example, I write ten words in the text-area,
then I move the cursor at the beginning of the second word
and activate the event (for example, click on a button):
is there a way to know that the cursor is at the beginning of the second
word?

I know that the text-area is considered as a string,
so I want the position of the cursor in that string
at the moment of the event activation.

Having just had to do this for an intranet page where we wanted
to be able to click on terms in a list and have them insert into
a textarea at the cursor position (for an internal wiki), I can
tell you that it is possible, but only in IE unless you replace
the textarea with a _Java_ based editor.

See http://www.faqts.com/knowledge_base/...d/1052/fid/130
for a starting point. The IE code appears to be based on Microsoft's
own code at

http://msdn.microsoft.com/library/de...us/dnwebteam/h
tml/webteam12032001.asp (see "O Cursor Where art thou?")

This works, but it's not very nice or easy.


I found this
http://www.faqts.com/knowledge_base/...html/aid/13562
to be better than your first suggested link.
Bye
Jul 23 '05 #4

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

Similar topics

3
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I...
0
by: Dusan Mihajlovic via .NET 247 | last post by:
Is it posible to set cursor position on the begining of selectedtext of text box. For example, I have text TEST in text box. Iwant to select ES character and cursor position between T and...
2
by: AP | last post by:
I am trying to find the integer value for the cursor position in a text box, in particular I want to find out if I am at the end of some text that I typed or at the beginning. I am using IE 6. ...
7
by: Steve | last post by:
does any one know a way to determine the position of the cursor in a text box. I would like to position a list next to the current position for context commands. I am using...
1
by: Tantra Veda | last post by:
Hello C# gurus, I have a question about finding cursor position in NumericUpDown control. On my form I have a numericUpDown control with 2 decimal places. I want to increment value in the numeric...
4
by: Billy | last post by:
Hi all, I'm building a text file from a database table using the ASP Write Method and would like to position the cursor in a specific column position before writing the fields. As I loop through...
4
by: Ubi | last post by:
Hi guys, I am loading a page with textareas containing text. By the default, the cursor goes at the beginning of the text. I would like to position the cursor at the end of the text instead. ...
4
by: Brandon McCombs | last post by:
Does anyone know of an easy way to set the position of the cursor in a TextBox? If I set text in the box that is longer than the length of the TextBox the position of the cursor is at the very end...
0
by: Alex9968 | last post by:
Is it possible to get position (in numbers) of the insertion cursor? As I understood, Text widget uses mark named INSERT to store it, which is available globally by just referencing INSERT, but how...
0
by: nagarjunt | last post by:
Hi, This is nag. I have a problem with infragistics7.1 UltraTextEditor control. I am using C# code in windows form. I have UltraTextEditor control(With multi line enabled) in my Windows...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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...
0
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.