Use javascript to surround selected text in a textarea
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4714192/insert-text-before-and-after-selection-in-textarea-with-javascript">Insert text before and after selection in textarea with javascript</a>  </p>
</blockquote>



<p>I need some help writing a script that will surround selected text in a textarea.</p>

<p>Example</p>

<pre><code>abc 123 xyz 789
</code></pre>

<p>I select 123 and then click a button that runs my script. The output should become:</p>

<pre><code>abc &lt;b&gt;123&lt;/b&gt; xyz 789
</code></pre>
