Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple layers of single quotes and Expected ')' error

Posted on 2006-07-11
3
Medium Priority
?
240 Views
Last Modified: 2006-11-18
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
0
Comment
Question by:jmanGJHS97
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 17081749
Try this one.

strNotes = escape(arrRow[5]);
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 2000 total points
ID: 17081765
does this work?

strNotes = replaceString(strNotes, "'", "\\'");
0
 
LVL 9

Author Comment

by:jmanGJHS97
ID: 17081815
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question