function insert_text(form_name, text_name, text_to_insert)
{
var txtarea = document.forms[form_name].elements[text_name];
txtarea.focus();
var theInsert=document.selection.createRange();
theInsert.select();
theInsert.text=text_to_insert;
return;
}
Потом в БОДИ
print "<a href=\"javascript:insert_text('".$form_name."', '".$text_name."' , '".$text."')\"><img src=\"smth.jpg\" alt=\"\"></a>";