You can make your CF structure avcailable in JS by using the toScript() function. This will replicate any CF variable, including complex data types like structures and arrays into the equivalent JavaScript data types. Granted, you still can't use the JS to interact with CF without AJAX, but if all you need is for the data to be available in JavaScript, toScript() might be a good choice, especially if your structure has numerous, or nested keys.
On 9/21/06, Charlie Griefer <[EMAIL PROTECTED]> wrote: > > you're still overlooking the client/server issue. > > when you create your structure, you're doing it on the server. that > has nothing to do with the client until you make it have somethign to > do with the client. > > e.g. > > <cfset students = structNew() /> > <cfset students.name = "Fred" /> > > <script type="text/javascript"> > var studentName = "<cfoutput>#students.name#</cfoutput>"; > alert(studentName); > </script> > > On 9/21/06, Richard White <[EMAIL PROTECTED]> wrote: > > 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:253954 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4