• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 17. Using JavaScript and ColdFus... > Passing Variables to JavaScript

Passing Variables to JavaScript

ColdFusion developers sometimes get confused about how to make the values of ColdFusion variables available to JavaScript. There are a lot of reasons why you might want to do this, as you'll see throughout the examples in this chapter.

There's only one conceptual leap that you need to make, and it's a pretty small one at that. You just need to realize that JavaScript variables are generally created and set within <script> blocks in an HTML page. Since those <script> blocks can be generated dynamically with ColdFusion (just like any other portion of an HTML page), all you need to do is to output the values of your CFML variables in the correct spots, generally right after the JavaScript var keyword.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint