Copy link to clipboard
Copied
I have a string that might contain 12345, or 12335,6789, or 123435,6789,9999, etc...unlimited
When I display, the string is very long, lengthwise. So I want to break it up and display one on top of another.
I started to use the Find function to location the postion of the comma, then used Mid function to get the first value, the repeat similar process to get the second and third values. This seems to work and the display is the way I want it.
Howver, I know I have three values inside the string, so I can adjust accordinly. What if I do not know how many values there are ? How would I separate to get the desired output ?
This is my code so far, based on three values :
<cfset pos1 = Find(",","#qry.carrierTracking#")>
<cfif pos1 is not 0>
<cfset carrier1 = #mid(qry.carrierTracking,1,(pos1 - 1))#>
<cfset carrier2 = #mid(qry.carrierTracking,(pos1 + 1),50)#>
</cfif>
<cfset pos2 = Find(",","#carrier2#")>
<cfif pos2 is not 0>
<cfset carrier2A = #mid(carrier2,1,(pos2 - 1))#>
<cfset carrier3 = #mid(carrier2,(pos2 + 1),50)#>
</cfif>
<cfif pos1 is not 0 and pos2 is not 0>
<cfoutput>#carrier1#<br>#carrier2A#<br>#carrier3#<br></cfoutput>
</cfif>
<cfset carrierTracking = replace(qry.carrierTracking, ",", "<br>", "all")>
Copy link to clipboard
Copied
Treat your string as a list.
Copy link to clipboard
Copied
ok, If it is treated as a string, how can I display the output with a line break after each comma ?
Copy link to clipboard
Copied
Wouldn't you just replace all the commas with a comma followed by a <br /> ?
--
Adam
Copy link to clipboard
Copied
<cfset carrierTracking = replace(qry.carrierTracking, ",", "<br>", "all")>