<script>
function addText(event){
document.getElementById("insertid").value +=
(event.srcElement || event.target).firstChild.nodeValue.toString();
}
</script>
<textarea id="inserid"></textarea>
<table onclick=addText(event)><tr><td>[bbcode][/bbcode]</td><td>[bbcode2][/bbcode2]</td></tr></table>
problem is whe i click on the bbcode or bbcode2 it inserts it at the end of whatever is in the textarea. im looking to insert it into where the user clicks(where the carat is)
like if a user entered in the textearea:
hey whats up
and the carrot was after hey then when they click the bbcode it enteres it as
hey[bbcode][/bbcode] whats up
how do i do that?