Link to home
Start Free TrialLog in
Avatar of jmanGJHS97
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_gray" 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
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Try this one.

strNotes = escape(arrRow[5]);
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmanGJHS97
jmanGJHS97

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