By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,627 Members | 1,682 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,627 IT Pros & Developers. It's quick & easy.

Single and double quote problem

P: n/a
Hi All-

I'm pretty sure this have been discussed earlier, but couldn't find a
solution to my problem.

<input type="submit"
value="Delete Parts"
onclick="return handleDeleteParts('ABC', 'MY

I'm using something (Struts ResponseUtils.filter()) which translate 'MY
DESCRIPTION' in such a manner that a double quote is replaced by &quot;
and a single quote to '

The problem is if there is a single quote (translated to ') i get a
javascript error (small error icon on the status bar)it says, "Error:
Expected ")"

if I change the above to:

<input type="submit"
value="Delete Parts"
onclick='return handleDeleteParts("ABC", "MY

it works fine, but a new error is introduced in that now i run into the
same problem is MY DESCRIPTION has a double quote in it.
Here is an actual line:

<input type="submit"
value="Delete Parts"

onclick="return handleDeleteParts('XF2',
''Mustang' Logo Fabric Bucket Seats')">

Any help is appreciated.

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Use String.fromCharCode(i) to replace the single and double quotes.

For example, if your string is O'douls, and you want it enclosed in
single quotes, replace the single quote with:


So an example line might look like:

fromCharCode documentation at MSDN:

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.