Skip to main content
Participant
March 25, 2008
Question

JS variables and CF ones

  • March 25, 2008
  • 3 replies
  • 501 views
Hi,there.

Is there any way to put variables of JavaScript into variables of ColdFusion?
Like below;

I'm sorry but my English is not pretty good.
Thanks.
This topic has been closed for replies.

3 replies

Participating Frequently
March 25, 2008
Here is also an interesting article:

JavaScript Variable Dump in Coldfusion
http://www.netgrow.com.au/files/javascript_dump.cfm

:)
Inspiring
March 25, 2008
holga_bz wrote:
> Hi,there.
>
> Is there any way to put variables of JavaScript into variables of ColdFusion?
> /*
> I'd like to declare a CF variable "bbb" and put JS variable "aaa" into it...
> */

Not in this manner. ColdFusion runs on the the server and JavaScript
runs on the client and never shall the two meet.

You can use ColdFusion to build dynamic JavaScript, a very powerful
tool. But to have JavaScript populate a ColdFusion variable, a new
request to the server must somehow be made. Any and all the methods to
making an HTTP request are valid either has GET or POST requests through
page refreshes, AJAX calls, whatever you care to do. But you must do
something to have the client send a request to the server.

Astonished_protector15C3
Participating Frequently
March 25, 2008
Hi

You can assign the coldfusion variable to javascript

<script>
var fname=<cfoutput>#firstname#</cfoutput>;

</script>