Ask a Question related to Macromedia ColdFusion, Design and Development.
-
dxsmith99 #1
Passing CF Arrays to javascript
Hello,
I have an 1 dimensional Coldfusion array that I need to access from Javascript.
When a user selects an item out of a list box, a call is placed to a
javascript function and the id value of the item selected is pass in.
I need to take that id and access the appropriate element within my array.
Once I have accessed the element whose index matches the passed in ID, I need
to display the contect within the array to the user.
If I am unclear please let me know. I am pretty desparate on this, I have
been working on it for more than a day and can not seem to get it to work.
Thanks so much in advance for any help given!!
Dallas
dxsmith99 Guest
-
Passing arrays of structs from C# web service to raw C++?
I have a C# webservice that returns an array of struct data back to a calling client. It works fine when tested via the ASMX page; however, I... -
Passing arrays to functions
OK, another quickie, How do I pass an array to a function? This is what I have, and the second function doesn't seem to be getting the array... -
Passing Arrays
Good day folks. I'm probably overlooking the obvious, but asking for feedback none the less =) Can you pass a multidimensional array to a self... -
Passing arrays through functions
Hi, I need to pass an array to a function, change it a little and return it to the main code. When i try it the webpage is displayed up until the... -
Passing arrays to SP
I have a transaction with several steps that I need to accomplish. I'm trying to decide if I should manage that transaction from my vb.net program... -
jonwrob #2
Re: Passing CF Arrays to javascript
You can't get it to work because CF is server side and Javascript is client
side and they cannot talk to each other.
What you might want to try is something like this:
<script language="Javascript">
var js_array = (#ArrayLen(cf_array)#);
<cfloop index="i" from="1" to="#ArrayLen(cf_array)#">
js_array[#i#] = #cf_array#;
</cfloop>
function your_function_here()
{
}
</script>
You need to create a java script copy of your array so that it exists on the
client side and your javascript function can access it.
JR
jonwrob Guest
-
sillyworm #3
Re: Passing CF Arrays to javascript
Hi DX, You can use the CFWDDX tag specifically for this task. It will work
like this: <cfwddx action='cfml2js' input='#yourArray#' output='outputVariable'
toplevelvariable='newJavascript'> This will automatically generate the
javascript necessarry to match your ColdFusion array. Simply output
#outputVariable# in your Javascript code to expose the javascript.
sillyworm Guest



Reply With Quote

