All you have to do is use the pound signs around the variable...just like in
Cf.  As long as it is declared before you put it in the JavaScript...you7
are fine.  However, you cannot do it the other way around as cf gets
processed before the javascript does :-(

Eric

Example...(switching ft and lt signs with forward slashes)

/cfset x=1/


/script language="javascript"/
Var pagenumber=#x#;
/ /script/ 

If you were doing something with pagenumber in javascript, it would have a
value of 1.

However you cant do the following...

/script language="javascript"/
Writeln("/cfset x=1/");
/ /script/

What you will get is the text of the tag and not the actual cfset...



-----Original Message-----
From: Richard White [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 21 September 2006 14:24
To: CF-Talk
Subject: Re: Javascript vs. cfscript

hi, thanks for your reply. I dont really understand how this works, i tried
to use the code you supplied but it didnt do as expected. can i not create a
variable in a cfset tag and then use it in the javascript. if i cant do this
how can i get around it?

i tried playing around with the code that you sent but couldnt get it to do
anything with the foo variable that you set in the cfset tag to 'bar'

basically what i am trying to do is create a structure in cfset tags:

<cfset students=StructNew()>
<cfset students.name="Fred">

then try to use that variable in the javascript, even for a simple alert
box:

<script type="text/javascript">
  alert(student.name);
</script>  

thanks



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:253952
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to