Home All Groups Group Topic Archive Search About

how to insert text into middle of textarea

Author
21 Jun 2005 8:42 PM
Rick Csucsai
Here is my dilemma: I have a text area where a user will type in a story. I
want them to be able to hit a button that will insert some text (reference
to an image that I will later parse) into the textarea at the point of the
cursor. Granted, this is easy enough to add something at the end of the text
that the user has already typed but what if I want to insert it into the
middle of pre-typed text. For example:

the user types paragraph 1. Then types paragraph 2. They then decide that
they wanted to insert the image into the middle of paragraph 1. I need for
them to be able to click where they want the insert at in paragraph 1, hit
the insert button, and then once the insert is done, they can continue
typing from where they clicked in paragraph 1.

So how can I tell where the cursor (some call it the caret) is within the
text area? Anyone have any ideas?

Author
24 Jun 2005 3:53 PM
Harolds
Take a look here:
http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130

Show quoteHide quote
"Rick Csucsai" wrote:

> Here is my dilemma: I have a text area where a user will type in a story. I
> want them to be able to hit a button that will insert some text (reference
> to an image that I will later parse) into the textarea at the point of the
> cursor. Granted, this is easy enough to add something at the end of the text
> that the user has already typed but what if I want to insert it into the
> middle of pre-typed text. For example:
>
> the user types paragraph 1. Then types paragraph 2. They then decide that
> they wanted to insert the image into the middle of paragraph 1. I need for
> them to be able to click where they want the insert at in paragraph 1, hit
> the insert button, and then once the insert is done, they can continue
> typing from where they clicked in paragraph 1.
>
> So how can I tell where the cursor (some call it the caret) is within the
> text area? Anyone have any ideas?
>
>
>