Si... ma scusa (oggi sono rinco!)
Ma quello che tu hai indicato come "Testo da formattare", che equivale alla selezione nella textarea, come la tiro fuori?
Ora il codice è:
codice:
function formatta(el,tag){
var obj=document.getElementById(el);
if (document.all) {
obj.focus();
var sel=document.selection;
var rng=sel.createRange();
rng.colapse;
rng.text='['+tag+']'+rng.text+'[/'+tag+']';
} else if(obj.selectionEnd){
var lng=obj.textLength;
var from=obj.selectionStart;
var to=obj.selectionEnd;
obj.value=obj.value.substring(0,from)+'['+tag+']'+obj.value.substring(from,to)+'[/'+tag+']'+obj.value.substring(to,lng);
}else obj.value+=sml;
obj.focus();
}