Revealing the position of the cursor in a text-area

P

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
 
M

MikeT

PeP said:
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/view.phtml/aid/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/default.asp?url=/library/en-us/dnwebteam/html/webteam12032001.asp
(see "O Cursor Where art thou?")

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

PeP

MikeT said:
"PeP" <[email protected]> wrote in message

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/view.phtml/aid/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/default.asp?url=/library/en-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
 
P

PeP

[cut]
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/view.phtml/aid/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/default.asp?url=/library/en-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/view.phtml/aid/13562
to be better than your first suggested link.
Bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top