What method are you using to cast your CF array over to a JS array?

William

-- 
William E. Seiter
 
Have you ever read a book that changed your life?
Go to: www.winninginthemargins.com
Enter passkey: goldengrove
 
Web Developer / ColdFusion Programmer
http://William.Seiter.com
-----Original Message-----
From: Richard White [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 18, 2008 10:06 AM
To: CF-Talk
Subject: empty array elements

hi,

i have battling with this problem for months and never thought to ask the
experts for their opinion :)

i have some instances in my code where i query a database and store the
values in cf array variables for some processing. however i have noticed
that if you try to store an empty value into an array element, it doesn't
create that array element at all. then when i translate those arrays over to
javascript arrays it causes problems. 

for example
i try to create an array but 1 element is empty
arrayName[1] = "one"
arrayName[2] = "" // empty string
arrayName[3] = "three"
arrayName[4] = "four"

when this is converted over to JS. Then in js code i am assuming that there
are 4 elements but of course there isnt so it produces an error. Plus they
are not in the correct position in the array:

arrayName[1] = "one"
arrayName[2] = "three"
arrayName[3] = "four"

i have so far got around it by checking whether it is an empty string when i
get it out of the database and if it is i set the value to a dash '-'. this
gives me the following:

arrayName[1] = "one"
arrayName[2] = "-"
arrayName[3] = "three"
arrayName[4] = "four"

then in js i can run some code that checks whether the value is a dash '-'
and if it is then it needs to treat it as an empty string.

surely there is a better way to do it than this. i would appreciate your
opinions and feedback. thanks very much

richard 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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

Reply via email to