• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Replace or append items in coldfusioin string

I have a form with some checkboxes. When the form is submitted, the items are saved as a string and separated by commas. So if the checkboxes for "bob", "larry" and "greg" were selected the form value is: bob,larry,greg

I need to take each of those values and add "@mycomp.com" and separate them with semi colons (except the last one). So, they would be: bob@mycomp.com; larry@mycomp.com; greg@mycomp.com

I'd also like to create a list with the values after they are set with the @mycomp.com.

Could someone assist?

Thank you.
  • 2
1 Solution
Something like ...

<!--- change delimiter from "," to "@mycomp.com;" --->
<cfset newList = arrayToList(listToArray(FORM.theFieldName), "@mycomp.com;")>
<cfif listLen(newList, ";")>
     <!--- append "@mycomp.com" to last element --->
     <cfset newList = newList &"@mycomp.com">
earwig75Author Commented:
You're the best.
Thanks. Glad I could help :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now