You can't mix JavaScript and ColdFusion like that. All the CF is ran server side, and then ONLY HTML and JS are sent to the browser.
The ColdFusion array is not accessible to your browser's JavaScript. JavaScript and CF do not execute side by side at the same time. The #session.milestone[i].name# code will be evaluated on the server before the browser ever sees the page. i in that context has to be a ColdFusion variable. A JavaScript variable will not work. My guess is you have defined a variable i somewhere else in ColdFusion to be equal to 5. I think you may need to do your loop on the server side with a Cold Fusion loop, or create a JavaScript array and then loop over that. ~Brad -----Original Message----- From: Richard White [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 01, 2006 4:06 PM To: CF-Talk Subject: very off referencing of session variables hi, i am trying to reference session variables in javascript and cant work out why i am getting an error: the code i am getting an error on is: for(i=1; i<="<cfoutput>#structcount(session.milestone)#</cfoutput>";i++) { alert("<cfoutput>#session.milestone[i].name#</cfoutput>"); } the milestone array in the session structure contains 4 elements starting from 1-4. If i output the structcount it does say 4 however, running this code tells me that element 5 does not exist in the milestone array. I am not even asking the loop to go as far as 5, i am just telling it to go from 1 to 4. if i test it with numbers instead of i then it works fine, as follows: alert("<cfoutput>#session.milestone[1].name#</cfoutput>"); alert("<cfoutput>#session.milestone[2].name#</cfoutput>"); alert("<cfoutput>#session.milestone[3].name#</cfoutput>"); alert("<cfoutput>#session.milestone[4].name#</cfoutput>"); this works fine. does anyone have any idea why it is coming up with the error on element 5 when the loop only goes from 1 to 4 even if i place a loop going from 1 to 2 it still says element 5 doesnt exist i would appreciate any help or suggesstions 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:258773 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4