Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eliminating last comma in my dynamic output 4

Status
Not open for further replies.

evergreean43

Technical User
Joined
May 25, 2006
Messages
165
Location
US
My current output of dynamic names in my variable (called dynNames) has a comma at the end.

I need to eliminate the last comma:
Jones, Smith, Baker, Johnson,

to look like this:

Jones, Smith, Baker, Johnson


My attempt to eliminate the last comma doesnt work because it eliminates all the commas:
Code:
<cfset myNames = REReplace(dynNames, ",$" "", "All")>

<cfoutput>#myNames</cfoutput>

Output from my bad attempt:
Jones Smith Baker Johnson

Please advise.

 
Thanks for all the help.

This is what finally worked.

I am not sure what ListAppend() function does?
I assume it adds each record find to a list?
Code:
<cfoutput query="otherquery" group="id">
#id#<br>
<cfset dynNames = "">
<cfoutput>
<cfset dynNames = listappend(dynnames,names)>
</cfoutput>
#dynNames#
</cfoutput>
 
Sorry typo on one line.

Here is what worked:
Code:
<cfoutput query="otherquery" group="id">
#id#<br>
<cfoutput>
[COLOR=red]<cfset dynNames = "">[/color]
<cfset dynNames = listappend(dynnames,names)>
</cfoutput>
#dynNames#
</cfoutput>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top