Problems parsing double quote
843835Jan 16 2002 — edited Jan 16 2002I have been trying to figure out my problem for several hours, but still didn't get it. Hope to get an idea from you guys. My code is as follows:
var astr;
var outCr ="|";
var outLf = "\u0000";
var cr = "\n";
var lf ="\r";
var ddQuote=""";
var dtQuote='\"';
astr = "<%=firstDesc%>";
astr.replace(outCr,cr);
astr.replace(outLf,lf);
astr.replace(ddQuote, dtQuote);
while (astr.indexOf(outCr) > 0) {
z = astr.indexOf(outCr);
astr = astr.substring(0, z) + cr + astr.substring(z+1,astr.length );
}
while (astr.indexOf(outLf) > 0) {
z = astr.indexOf(outLf);
astr = astr.substring(0, z) + lf + astr.substring(z+1,astr.length );
}
while (astr.indexOf(ddQuote) > 0) {
z = astr.indexOf(ddQuote);
astr = astr.substring(0, z) dtQuote astr.substring(z+1,astr.length );
}
document.form1.description.value=astr;
The value of firstDesc is a very big string from the database that contains carriage return, linefeed, single quote and double quote. It needs to be displayed in a HTML text area. Now everything works fine except the double quote. A firstDesc value containing double quote will not appear in the text area, and it even stop my jsp page and disable other buttons. But if I get rid of the code handling the double quote, everything works fine. What's the problem?