Skip to main content
September 7, 2011
Question

Convert coldfusion variable to javascript variables

  • September 7, 2011
  • 1 reply
  • 2043 views

Hy everybody.

I've tried for this the following:

var #toScript(array[1], "x")#;

and it's working fine.

I've tried to do the following:

var #toScript(cars[1], "x[1]")#;


and it's not working. I want to generate about one hundred javascript variables dinamically, and put toScript inside a CF loop or JS for.

Any ideas?

Thanks.

    This topic has been closed for replies.

    1 reply

    Inspiring
    September 7, 2011

    Simplify it.  I do stuff like this:

    var #toScript(cf_categoryArray, "js_categoryArray")#;

    which copies the entire array.  Also, remember that js arrays start at element 0, not 1.

    September 7, 2011

    The thing is that it does copy the entire array.

    All i want to do is the same operation for another 99 arrays.