i want to replace some selected character from my text-area with some string. To do this i wrote the following JavaScript code
var old_tag = "[";
var tag= " <xsl:value-of select = ";
var endtag= " />";
var txt='';
if(document.selection)
{
txt = document.selection.createRange().text
document.selection.createRange().text = txt.replace(/\[/g, tag);
document.selection.createRange().text = txt.replace(/\]/g, endtag);
}
But this code replacing one character at one line and another in another line. For two line of replacement code it is showing four lines.
Plz improve this code so that i can do my work in a single line.
Thanks