473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2908


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: isv | last post by:
Hi! Could anyone give some advice? Is there a way to get the current position of cursor within textarea with Javascript? I need to insert a specified text into current cursor position...
2
by: Asad | last post by:
I have a form on a page that has several textareas, and textboxes inside a table (so the table containing the textboxes is also inside the FORM tag). I want to replace the textareas with simple...
4
by: Dean A. Hoover | last post by:
Is there an example somewhere of a function that will take 2 parameters: text and a text object (input type=text or textarea) and insert that text using the current selection point(s) for the...
3
by: PeP | last post by:
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...
1
by: Scott Chapman | last post by:
I am working with Python (psycopg). I have HTML with embedded Python that I'm inserting into a database and it could contain any character. Single quotes, at least, must be escaped (to two...
3
by: BradC | last post by:
I have a big VS 2002/2003 annoyance, and wondering if there is a way to turn it off: Put your cursor at the start of an indented line of code inside a function. (right before the first...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
12
balabaster
by: balabaster | last post by:
How do I insert text into a textarea at the current cursor position in JavaScript?
4
by: liberty1 | last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help. PROBLEM NUMBER 1: Using PHP and MySQL, I am able to upload...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.