Helo im creating a simple text editor in which the user can bold some text for a page. I call it like so
and bold is as folows
I thought it was working until i noticed the fundamental flaw..
If text is "Friggin right!" and i select "rig" from the word "right" then the text comes back
"F<B>rig</B>gin right"
i know of using g and i for global and insensitive casing but i cant seem to find a way around this. Does any one else know a way?
Thanks alot for any help.
MCP, .Net Solutions Development <%_%>
Code:
<input type="button" id="Button1" value="Bold" onclick="bold(document.selection.createRange().text)" />
Code:
function bold(SelectedText){
if(IsDesign){var currentText = document.getElementById("Designview").innerHTML;} else {var source = document.getElementById("htmlview").value;};
UpdatedText = currentText.replace(SelectedText,'<B>' + SelectedText + '</B>');
alert(UpdatedText);
return UpdatedText;
}
If text is "Friggin right!" and i select "rig" from the word "right" then the text comes back
"F<B>rig</B>gin right"
i know of using g and i for global and insensitive casing but i cant seem to find a way around this. Does any one else know a way?
Thanks alot for any help.
MCP, .Net Solutions Development <%_%>