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
Solved

Having trouble escaping variables in javascript

Posted on 2010-11-16
1
207 Views
Last Modified: 2012-05-10
I have the below javascript snippet: #url.typ# and #url.dept# are coldfusion variable on my site.  Some of the variables have an apostrophe in them, ex. men's   Can I escape them inside this snippet somehow?
<script type='text/javascript'>
product.Catalog.init({
    filters: {
        category: ['#url.typ#'],
        department: ['#url.dept#']
    },
    maxFacetOptions: 10
});
</script>

Open in new window

0
Comment
Question by:rkoechel
1 Comment
 
LVL 16

Accepted Solution

by:
jmatix earned 500 total points
ID: 34151378
If you need to escape only apostrophies (not worried about double quotes (") in those values),  then you can use double quotes to surround the JS values as:

<script type='text/javascript'>
product.Catalog.init({
    filters: {
        category: ["#url.typ#"],
        department: ["#url.dept#"]
    },
    maxFacetOptions: 10
});
</script>

Open in new window

0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

839 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