Inserting characters at current cursor point in textarea

M

M Wells

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.
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top