1<script type="text/javascript">
2<!--
3 function formatText (tag) {
4 var selectedText = document.selection.createRange().text;
5
6 if (selectedText != "") {
7 var newText = "[" + tag + "]" + selectedText + "[/" + tag + "]";
8 document.selection.createRange().text = newText;
9 }
10 }
11//-->
12</script>
13
14<form name="my_form">
15 <textarea name="my_textarea"></textarea><br />
16 <input type="button" value="bold" onclick="formatText ('b');" />
17 <input type="button" value="italic" onclick="formatText ('i');" />
18 <input type="button" value="underline" onclick="formatText ('u');" />
19</form>