-
1. Re: handle single quote with javascript
Dan Bracuk Nov 21, 2011 6:10 PM (in response to Phinehas1234)urlencodedformat
-
2. Re: handle single quote with javascript
insuractive Nov 21, 2011 7:06 PM (in response to Dan Bracuk)You can also escape quotation marks and apostrophes in JavaScript using the backslash: \'
-
3. Re: handle single quote with javascript
cfinnov Nov 22, 2011 4:28 AM (in response to Phinehas1234)<cfset CompName = "D'zousa and CO">
<cfoutput>
<input type="hidden" name="MyCompany" id="MyCompany" value="#CompName#">
<a href="##" onclick="javascript:mypopup()">#(CompName)#</a>
</cfoutput>
<script language="javascript">
function mypopup()
{var comp = '';
comp = document.getElementById('MyCompany').value;
alert(comp);
}
</script> -
4. Re: handle single quote with javascript
insuractive Nov 22, 2011 6:38 AM (in response to insuractive)Let me rephrase my answer since I realized that might not have made sense - there is a typo in your syntax in how you are trying to reference the apostrophes. When defining your replace statement if you use the same character as the text qualifier in the function (in this case an apostrophe), you need to escape the character you are searching for in CF. The text to replace cannot be three apostrophes:
'''
Your choices are using a different qualifier (quotation marks - will work fine here since there is no conflict between the server side code and client side code) or escaping the qualifier (apostrophe) in CF by doubling it.
Does this work:
<a href="##" onclick="javascript:select('#replace(getList.company_name,"'","\'","ALL")#')">#getList.co mpany_name#</a>


