You need to check the item to see if it's null. <cfset a = arrayNew(1)> <cfset a[1] = "a"> <cfset a[3] = "c">
<cfoutput> <script> var #toScript(a,'data')# for(var i=0;i < data.length; i++) { if(data[i] != null) alert('pos '+i+' is '+data[i]); } </script> </cfoutput> On Fri, Jun 13, 2008 at 8:18 AM, Richard White <[EMAIL PROTECTED]> wrote: > hi > > i am using the following method to translate coldfusion into javascript > arrays: > > <cfoutput> > var #toscript(array1,"jsArray1")#; > var #toscript(array2,"jsArray2")#; > </cfoutput> > > however, these arrays sometimes don't contain any elements and if this is the > case then i get a 'missing variable' javascript error. > > how would i get around this? > > thanks > > richard > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307408 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4