• Advertisement
Sign in to follow this  

[web] Inserting objects into textarea's

This topic is 4580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
I have personally never seen it done. Looks like your users are just going to have to cut and paste the tags to get them where they want them.

Share this post


Link to post
Share on other sites
It's possible. Take a look at the javascript in the "new topic/post reply" form on any phpBB powered website (like, for example, phpBB's own site).

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
Sign in to follow this  

  • Advertisement