Link to home
Start Free TrialLog in
Avatar of kgsoft_sys
kgsoft_sys

asked on

How to handle single quotation mark....

Dear experts..

i have a JSP page with the following code calling a JavaScript function...

<A href="javascript:checkPage('CH'NG BENG GUAN')">

it is a hyperlink...whenever i click this hyperlink..the Javascript will submit the form with the parameter to the Java Servlet to search for the details in hashtable based on this key:

CH'NG BENG GUAN

it is a person's name with a single quot mark (') in the third position..the problem is that JavaScript will give this as an error as this :

Line: 1
Cahr: 15
Error: expected ')'

so is there any special character we need to place together with the single quotation mark..so that Javascript can pass it to the function successfully...

it is quite urgent...pls give the solution asap..tq
ASKER CERTIFIED SOLUTION
Avatar of alexcohn
alexcohn
Flag of Israel 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 webwoman
webwoman

Try escape.

<A href="javascript:checkPage(escape('CH'NG BENG GUAN'))">
How do you handle e.g. the next line:

document.writeln('<A href="javascript:checkPage('CH'NG BENG GUAN')">');

The string inside, which includes both single and double quote, comes from c-code and I cannot change it.

This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or so. I appreciate any comments that would help me to make a recommendation.
 
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
 
ahosang
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to alexcohn
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
Per recommendation, force-accepted.

Netminder
EE Admin