How do I set a variable in Javascript,
then check for its value in CF?
CFPARAM Name=JS Default=False
script type=text/javascript
var JS;
JS = true;
/script
CFIF JS is true
do something
CFELSE
do something else
/CFIF
Rick
you can't use CF to check for the existence of a JS variable. one of
them is server side and one is client side.
the JS variable is set after the page reaches the browser, at which
point CF has done its job.
On 4/20/07, Rick Faircloth [EMAIL PROTECTED] wrote:
How do I set a variable
You'd have to use some form of behind the scenes processing.
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Friday, April 20, 2007 12:31 PM
To: CF-Talk
Subject: How do I set this variable, then...
How do I set a variable in Javascript,
then check for its value
AJAX
~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR
Archive:
You can't. JS is client side and CF is server side, and never the two
shall meet.
You will have to send the JS value to the server with some kind of
request. Either in the request of an entire page, as an URL value for
example. Or with AJAX as a separate request.
Well can can cause coldfusion to set javascript variables based on
coldfusion variables
cfset foo = structNew()
cfset foo.bar1 = 1
cfset foo.bar2 = 2
cfset foo.bar3 = 3
script language=javascript
cfwddx action=CFML2JS input=#foo# toplevelvariable=foo
alert(foo[bar1]);
/script
but the
Thanks for the responses, everyone!
Rick
-Original Message-
From: Rick Root [mailto:[EMAIL PROTECTED]
Sent: Friday, April 20, 2007 3:54 PM
To: CF-Talk
Subject: Re: How do I set this variable, then...
Well can can cause coldfusion to set javascript variables based on
coldfusion
Well can can cause coldfusion to set javascript variables based on
coldfusion variables
I like to describe this as building Dynamic JavaScript with CFML, just
like CFML makes Dynamic HTML. It helps keep it clear in my mind that CF
is building the JavaScript and once it is completely
8 matches
Mail list logo