Javascript: Help needed to modify a script -- trying to insert a "special character" into a text field at the point where cursor

Hello experts.  I have a text area which a user can modify.  I need them to be able to insert a symbol into the text area (which they can).  However the symbol is always inserted at the end of the text (see code snippet below).  I need the symbol to be inserted at the point where the cursor is when the user inserts (so in the snippet below, i want a TM symbol inserted where the ">>>" are and not after the word "always" at the end.

Is this possible?

Thank you so much.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Experts Sample</title>
<script type="text/javascript">
function addText_myText(text){
  document.getElementById('myText').value += text;
<form action="" method="post" name="Bioform" id="Bioform">
<a href="#" onClick="addText_myText('&#174;');updatetext('myText','repmyText_tab1','htext');" myText="Insert &#174; symbol">&#174;</a> <a href="#" onClick="addText_myText('&#8482;');updatetext('myText','repmyText_tab1','htext');" myText="Insert &#8482; symbol">&#8482;</a><br>
<textarea cols="30" rows="10" name="myText" id="myText" onKeyDown="updatetext('myText');" onKeyUp="updatetext('myText');">This is a long paragraph.  I'd like to insert a trademark symbol here >>>.  However it will always insert at the end of this text.  Can this script be modified to insert symbol where cursor is placed?  Thank you as always.</textarea>

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try the below i made for another question on here:

This will insert the TM or what ever symbol you pass in where the cursor is. You can also highligh text and it will append the symbol to the end of it.
<script type="text/javascript">
        function setColor(a) {
                var seltxt=''
                var textbox = document.getElementById('inputforum');                    
                if (document.selection) { // for IE                     
                        var sel = document.selection.createRange();
                        sel.text = sel.text + a;
                } else if (typeof textbox.selectionStart != 'undefined') { // for FF, Opera etc...
                        var len = textbox.value.length;
                        var start = textbox.selectionStart;
                        var end = textbox.selectionEnd;
                        var sel = textbox.value.substring(start, end);
                        var replace = sel + a;
                        textbox.value = textbox.value.substring(0,start) + replace + textbox.value.substring(end,len);
<textarea id="inputforum"></textarea>
<input type="button" onclick="setColor('&#174;')" value="Insert TM" />

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
whaleykAuthor Commented:
That's beatufiul :-)  Thank you very much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.