469,898 Members | 1,792 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Inserting characters at current cursor point in textarea

Hi All,

I've been checking the online javascript libraries for code that will
show me how to insert characters at the current cursor point in a
textarea form field to help me markup content I write for my site.

Unfortunately, all I've been able to locate are plugin applets that
give wysiwig functionality, which is not what I'm looking for.

So I'm wondering if someone can provide some code, or point me to some
code, that will respond to a click on a button by inserting, as an
example, the following text at the current cursor position:
"<strong></strong>".

Ideally, what I'd like to do is if text is highlighted, then put
"<strong>" on one side, and "</strong>" on the other, and if no text
is highlighted, then simply insert "<strong></strong>" at the current
position and re-position the cursor so that it is between the
characters "><" so I can start typing straight away.

Any help with this would be immensely appreciated!

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.
Jul 20 '05 #1
1 2753


M Wells wrote:

I've been checking the online javascript libraries for code that will
show me how to insert characters at the current cursor point in a
textarea form field to help me markup content I write for my site.


Have a look at
http://www.faqts.com/knowledge_base/...d/1052/fid/130
amd
http://www.faqts.com/knowledge_base/.../13562/fid/130
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by isv | last post: by
4 posts views Thread by Dean A. Hoover | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.