function ReplaceTextarea() {
var obj,objSel,strValue,nStart,nEnd;
obj = document.getElementsByName("text")[0];
if ( document.all ) {
objSel = document.selection;
obj.focus();
strValue = objSel.createRange().text;
if ( strValue == '' ) {
return;
}
objSel.createRange().text = "<b>" + strValue + "</b>";
}
else {
if ( obj.selectionEnd == obj.selectionStart ) {
return;
}
nStart = obj.selectionStart;
nEnd = obj.selectionEnd;
strValue = obj.value.substring(
nStart,
nEnd
);
strValue =
obj.value.substring(0, nStart) +
"<b>" +
strValue +
"</b>" +
obj.value.substring(nEnd,obj.value.length);
obj.value = strValue
obj.setSelectionRange(
nStart,
nEnd + 7);
obj.focus();
}
}