Neat Trick With ValueList()

Posted September 6, 2006 at 6:06 PM

Tags: ColdFusion

This is just a quick little trick for outputting a list of items with proper spacing. You can use ColdFusion ValueList() using a delimiter that has both a comma AND a space in it: ", ". While this is not really a valid delimiter, which is defined as one character, the ValueList() method will still use both characters when creating the delimited list. Now, you have a nicely spaced list.

 Launch code in new window » Download code as text file »

  • <cfquery name="qTags" datasource="...">
  • SELECT
  • name
  • FROM
  • tag
  • ORDER BY
  • name ASC
  • </cfquery>
  •  
  • <!--- Output nicely formatted tag list. --->
  • Tags: #ValueList( qTags.name, ", " )#

Download Code Snippet ZIP File

Comments (1)  |  Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page



Keep your Web site content fresh and your overhead costs low with Savvy Content Manager

Reader Comments

I love CF's list functions. :)

Of course, for the other sort of lists, you can also do this:
<ul><li>#ValueList( qTags.name, "</li><li>" )#</li></ul>

which has come in handy for me on a couple of occasions.

Posted by Peter Boughton on Sep 7, 2006 at 4:27 AM


Post Comment  |  Ask Ben


Home   |   Web Log   |   ColdFusion   |   Projects   |   Resume   |   Job Form   |   Search   |   Contact
Epicenter Consulting - Custom Software Solutions for Business Evolution HostMySite.com - The Leader In ColdFusion Hosting