jmanGJHS97
asked on
Multiple layers of single quotes and Expected ')' error
I am trying to build an HTML string on the client side, using data passed from a database query on the server side. Here is a sample of what I'm doing:
strNotes = arrRow[5];
strNotes = replaceString(strNotes, "'", "\'");
strOnMouseOver = 'ddrivetip(\'Notes: ' + strNotes + '\', 150);changeStyleRow(' + i + ', \'checkbook_entry_over\'); ';
objString.append('<TD ID="date_' + i + '" CLASS="checkbook_entry_gra y" ONMOUSEOVER="' + strOnMouseOver + '" ONMOUSEOUT="' + strOnMouseOut + '" ONCLICK="' + strOnClick + '">' + strDate + '</TD>');
This code works just fine, unless arrRow[5] contains an apostrophe. If it does contain one, I get the Expected ')' error. Also, if I change this:
strNotes = replaceString(strNotes, "'", "\'");
to something like this:
strNotes = replaceString(strNotes, "'", "XXX");
The code works fine.
What am I missing?
jmanGJHS97
strNotes = arrRow[5];
strNotes = replaceString(strNotes, "'", "\'");
strOnMouseOver = 'ddrivetip(\'Notes: ' + strNotes + '\', 150);changeStyleRow(' + i + ', \'checkbook_entry_over\');
objString.append('<TD ID="date_' + i + '" CLASS="checkbook_entry_gra
This code works just fine, unless arrRow[5] contains an apostrophe. If it does contain one, I get the Expected ')' error. Also, if I change this:
strNotes = replaceString(strNotes, "'", "\'");
to something like this:
strNotes = replaceString(strNotes, "'", "XXX");
The code works fine.
What am I missing?
jmanGJHS97
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
pravinasar,
I had thought of that too, but that just puts %27, etc in the string. So that's not going to do.
knightEknight,
That worked like a charm. Thanks very much. I had tried "\'\'" previously, but to no avail. Thanks for your help.
jmanGJHS97
I had thought of that too, but that just puts %27, etc in the string. So that's not going to do.
knightEknight,
That worked like a charm. Thanks very much. I had tried "\'\'" previously, but to no avail. Thanks for your help.
jmanGJHS97
strNotes = escape(arrRow[5]);