how to insert text into middle of textarea

Discussion in 'ASP .Net Web Controls' started by Rick Csucsai, Jun 21, 2005.

  1. Rick Csucsai

    Rick Csucsai Guest

    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?
    Rick Csucsai, Jun 21, 2005
    #1
    1. Advertising

  2. Rick Csucsai

    Harolds Guest

    Take a look here:
    http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130

    "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?
    >
    >
    >
    Harolds, Jun 24, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tano

    insert a char in the middle of a string

    tano, Aug 9, 2004, in forum: C Programming
    Replies:
    7
    Views:
    394
    Christopher Benson-Manica
    Aug 11, 2004
  2. Mr. Ken
    Replies:
    1
    Views:
    285
    Kai-Uwe Bux
    Jun 2, 2006
  3. Paul Gorodyansky
    Replies:
    7
    Views:
    208
    Martin Honnen
    Feb 6, 2005
  4. cyprian

    insert text dynamically into textarea

    cyprian, Jul 18, 2007, in forum: Javascript
    Replies:
    6
    Views:
    129
    David Mark
    Jul 23, 2007
  5. globalrev

    insert javascrpt into textarea?

    globalrev, May 11, 2008, in forum: Javascript
    Replies:
    15
    Views:
    210
    Dr J R Stockton
    May 12, 2008
Loading...

Share This Page