471,316 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 4705
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dusan Mihajlovic via .NET 247 | last post: by
2 posts views Thread by AP | last post: by
7 posts views Thread by Steve | last post: by
1 post views Thread by Tantra Veda | last post: by
4 posts views Thread by Brandon McCombs | last post: by

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.