1

In coldfusion I have this part of the jquery ui slider script:

$("#slider-range_sun").slider({
   range: true,
   min: 0,
   max: 1440,
   step: 15,
   values: [375, 1020],

The last line where it says values: [375, 1020] I need to set the numbers with coldfusion variables that are coming from the DB. Putting cfoutput around that line and outputting the variables with pound signs breaks the jquery. Any thoughts on how to do this?

4
  • Putting cfoutput around that line...breaks the jquery That causes a CF error because CF thinks the pound sign in #slider is the beginning of a CF variable. When you need a literal pound sign, escape it by using 2 pound signs: ##slider
    – SOS
    Commented Jul 28, 2021 at 19:32
  • 1
    Does this answer your question? Is there a way to escape pound character (#) in ColdFusion?
    – SOS
    Commented Jul 28, 2021 at 19:32
  • Wait a second you are right. I did have a cfoutput around that #slider line. I missed that and it works now after escaping it. Thanks!
    – spacerobot
    Commented Jul 28, 2021 at 19:36
  • Okay, good. Glad you got it working
    – SOS
    Commented Jul 28, 2021 at 19:42

1 Answer 1

4

If this is all just inline JavaScript in a CFM file, you can do this to avoid the jQuery selector entirely:

$("#slider-range_sun").slider({
    range: true,
    min: 0,
    max: 1440,
    step: 15,
    values: <cfoutput>[#variableA#, #variableB#]</cfoutput>,

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.