|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a list like ",89,90,,87". When I use cfloop go to through it, I only get 3 values instead of 5 with 2 nulls. How do I specify the <cfloop> tag to return 5?
I want to have something like this: <tr><td></td><td>89</td><td>90</td><td></td><td>87</td></tr> Instead, I get this: <tr><td>89</td><td>90</td><td>87</td></tr> Thanks in advance for any help! Stelly |
|
#2
|
|||
|
|||
|
The unfortunate answer is there is no way to get CFLOOP to do this on its own. CF treats multiple null delimiters as one delimiter, which is a benefit in some situations and a pain in the butt in others. You could either send the string in with spaces between the delimiters, or run a replace function that adds a space after each delimiter, but then you must remember to trim() the value when you use it, like this:
<cfset list = "1,2,3,,5,,,,9,10"> <cfset counter = 0> <cfoutput> <cfloop index="thisElement" list="#replace( list, ',', ', ', 'All' )#" delimiters=","> <cfset counter = counter + 1> Element #counter#: #trim( thisElement )#<br> </cfloop> </cfoutput> A custom tag or function could also handle this pretty easily. |
|
#3
|
|||
|
|||
|
Thanks for the tip!
Stelly |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > cfloop list doesn't return null values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|