Sign in to follow this  
onceloving

[web] Inserting objects into textarea's

Recommended Posts

I've searched around for a couple of hours, and I can't find what I need, or it is way too complex. How can I insert a specific tag at the cursors position by clicking a button?
<html>
<script language="JavaScript" type="text/JavaScript">
function sendText(e, text)
{e.value=e.value + text;}
</script>
<body>
<img name="image" width="300" height="200" onClick="sendText(document.form1.taupdate, '<font color=red>')">
<br>
<form name="form1" method="post" action="">
<textarea name="taupdate" cols="30" id="taupdate"></textarea>
</form><
</body></html>

This adds text to the end of it, but how can I add text to wherever the cursor is?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can actually insert text where the cursor is. Visit http://www.alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this